HELP HELP HELP Passing proc to method


#1

my code:

ages = [23, 101, 7, 104, 11, 94, 100, 121, 101, 70, 44]

under_100 = Proc.new do
ages.each < 100
end

youngsters = ages.select(&under_100)

instuctions:
Now we'll be using the ages array. Create a variable called youngsters and set it equal to calling .select on ages, and pass in your under_100 proc to filter for the ages that are less than one hundred. Remember to pass &under_100 to convert your proc to a block!

this part was okay according to the last exercise:

ages = [23, 101, 7, 104, 11, 94, 100, 121, 101, 70, 44]

under_100 = Proc.new do
ages.each < 100
end

i only added the last line.
its says:
Oops, try again.
Your code doesn't look quite right. Check the Hint if you need help!

hint: Your syntax should look like this:

youngsters = ages.select(your_proc)

Where your_proc is the under_100 proc. Don't forget the ampersand!

What did i do wrong? I'm way to long on this exercise :frowning:


#2

Here's the code that worked for me:
ages = [23, 101, 7, 104, 11, 94, 100, 121, 101, 70, 44]

under_100 = Proc.new { |num| num < 100}

ages.select(&under_100)

The select will iterate through each number so you don't need to do .each in your proc. Then just make sure to have a .select after your proc.


#3

me too
under_100=Proc.new { |x| x < 100 }
youngsters = ages.select(&under_100)


#4

This code work for me:

ages = [23, 101, 7, 104, 11, 94, 100, 121, 101, 70, 44]

Add your code below!

under_100 = Proc.new { |num| num < 100}

youngsters = ages.select(&under_100)


#5