Seemingly correct code; What am I doing wrong?


#1

//Here at the amusement park, you have to be four feet tall
//or taller to ride the roller coaster. Let's use .select on
//each group to get only the ones four feet tall or taller.

group_1 = [4.1, 5.5, 3.2, 3.3, 6.1, 3.9, 4.7]
group_2 = [7.0, 3.8, 6.2, 6.1, 4.4, 4.9, 3.0]
group_3 = [5.5, 5.1, 3.9, 4.3, 4.9, 3.2, 3.2]

//Complete this as a new Proc
over_4_feet = Proc.new { |height| height >= 4.0 }

// Change these three so that they use your new over_4_feet Proc
can_ride_1 = group_1.select($over_4_feet)
can_ride_2 = group_2.select($over_4_feet)
can_ride_3 = group_3.select($over_4_feet)

Above is my code, but I'm not sure what I'm doing wrong. It won't let me pass the lesson. Can anyone tell me what I'm doing wrong?


#2

Hey

It seems that you're using the wrong symbol when passing the Proc, as you need to use & instead of $
By using $over_4_feet, you're trying to pass a global variable as a parameter instead, which is why ruby will respond with "wrong number of arguments(1 for 0)".
Global parameter is something you will learn more about in later lessions.

Also, not sure if this might just be a formatting error when making the post or not, but single line comments in ruby starts with #, and not //


#3

OMGGGGG that was driving me crazy. Thanks so much. It always seems to be the little itty bitty things which frustrate the most...

and yeah i just used // because Java is my first language and the hash tag

seems to make text really big