8. Why Procs? What am I doing wrong?


#1

I dont see why my proc is not accepted.


#2

oh no, its the brackets!


#3

hehehe yea, try using the brackets.


#4

same problem here

Is this right

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]

over_4_feet = Proc.new do |height|

height>4
end

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}


#5

Your code looks right to me, but change the brackets from { } to ( )


#6

@objectrockstar42395 height should be…

height >= 4


#7

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]

over_4_feet = Proc.new {|height| height >= 4}

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)

why does the editor return only the 3rd group? I pass the lesson but can figure out how to return each group.


#8

It's only suppose to return the last group. Remove the 3rd group and it will display the 2nd group. Remove both the 2nd and 3rd group and it will display the 1st group.


#9


#10

don kno why it says so....


#11


#12

just now figured ...guess spaces are not to be...


#13

How can you get all three group's to print? puts?


#14

try using the brackets!!!


#15

Just discovered this problem with space exactly as you did, and I was stuck on something in the last unit for 2 days over the same problem. I was under the impression that Ruby ignores blank space and I wish CodeAcademy could make a point of mentioning when spaces are important in these exercises.

Can someone knowledgeable perhaps generalize in a few sentences how Ruby deals with spaces and when they are important (if that's possible)?


#16

The most common problems:

  • {} instead of () due to Lazy Copy Paste programming...
  • A space between method and ( starting brace. This is somewhat surprising! CA
    should educate the users about this peculiar aspect of Ruby. RUBY
    needs to fix this if possible!

#17

It works for me. This is my code:

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]

over_4_feet = Proc.new do |height|
height >= 4
end

can_ride_1 = group_1.select { |height| height >= 4 }
can_ride_2 = group_2.select { |height| height >= 4 }
can_ride_3 = group_3.select { |height| height >= 4 }


#18

I did have the smae problem butu I managed to solve it without people that lauged and giggled like a bunch of monkeys


#19

refresh the page try to


#20

I believe .select is a method. There should not be space between method with argument.
lets take an example. You write method multiply_by_2 with single parameter.
so when you call your method with parameter we do not call it with space between.

Multiply_by_2 (2)

I guess by default it does not work.