Blocks,Procs and Lambdas. Creating a lambda


crew = {
captain: "Picard",
first_officer: "Riker",
lt_cdr: "Data",
lt: "Worf",
ensign: "Ro",
counselor: "Troi",
chief_engineer: "LaForge",
doctor: "Crusher"

Add your code below!

first_half = lambda do |r,n| n <"M"

n =

Last line code to check that things are fine, otherwise will just let you go.

It will print:
{:lt_cdr=>"Data", :chief_engineer=>"LaForge", :doctor=>"Crusher"}


It will RETURN this yes. I have the same result as you, what is your issue with this code?


from what i see is that is requested to find only |n| not |r,n| and it finds it, but no code is requested to display what was found. Last line, added, extra line allow us to see what was found. It found data from M to A like Data, La Forge... but also there is no code to display only |n|, and that is why |r,n| is on the screen. Note: is also find to add some code to display only |n|.
Hope it gest clear .


Your code is not made to find n or r. It's made to apply a selection on an hash.

By giving this criteria in your lambda:

n > "M"

select will apply the selection on the elements (the whole elements, key AND values) which respond to this criteria, but it will not only display the values just because the criteria of selection was the value. It will display all the elements (key and value) whose values are greater than the string "M".