21. Undefined method '<' for nil:NilClass


#1

I don't understand what this error is trying to communicate.

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


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 {|x, y| x[y] if x[y] < "M"}

a_to_m = crew.select(&first_half)

#2

first_half = lambda {|x, y| x[y] if x[y] < "M"}

a_to_m = crew.select(&first_half)

This bit of code suddenly worked when I changed it to:

first_half = lambda {|x, y| y < "M"}

a_to_m = crew.select(&first_half)

I don't know why it didn't like the longer version. It gets supplied two arguments by crew.select.