Passing Your Lambda to a Method


#1



https://www.codecademy.com/courses/ruby-beginner-en-L3ZCI/3/5?curriculum_id=5059f8619189a5000201fbcb


Instruction: create a variable called a_to_m and set it equal to calling .select on crew, and pass in your first_half lambda to filter for the names that are before "M" in the alphabet. Remember to pass &first_half to convert your lambda to a block!

My code seems to be correct. What is wrong?


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{|profession, name| name<"M"}
a_to_m = crew.select (&first_half)


8. Why Procs?
#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.