Can somone help me with the .collect method?


fibs = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]

Add your code below!

This is what i did.

doubled_fibs = fibs.collect { |p| puts p * 2 }

And it tells me that the number 2 isnt included in the array. Then when i add a 2 to the array it tells me to not modify array lol.

Replace this line with your code.



Read the definition

The collect method takes a block 
and applies 
the expression in the block 
to every element in an array.

So you want to double all elements of an Array
you then use

doubled_fibs = fibs.collect { |p| p * 2 }


Hi man i have a new problem since i finished the challenge you answered mind helping me with it?


Please read

Present the FULL code you are using now
specify what you do not understand.....


This is the full code......

floats = [1.2, 3.45, 0.91, 7.727, 11.42, 482.911]
# Write your code below this line!

round_down = {|o| o.floor }
# Write round_down = proc.New {|o| o.floor }your code above this line!
ints = floats.collect(&round_down)

Code academy respondes by saying tried to create probject without block.


Try it by using


As you can see i used its next to the floor block.


@codecrimson, your block is not complite as you should to create integers from the numbers in array. I guess that there are also some different ways to get this purpose. This one works for me:

round_down = { |n| n=n-(n % 1)}