Using Code Blocks lesson 5/11


#1

Please help. I have no idea what to do. I feel so dumb. The hint does not help me.

[1, 2, 3, 4, 5] { |i| puts 5 }
end

Currently, the second .each will print out 5 five times (since it will print 5 for each item in the array, and there are five items). Modify the block so it will print each item in the array multiplied by five.


#2

The block should be putting the iterator value:

[1, 2, 3, 4, 5]  { |i| puts i }

Not sure what the end is doing. It's not part of the code we can see.


#3

I was just trying different things. My problem is that I do not know the syntax to have each item in the array be multiplied by 5.
Please help. I been stuck here for hours.
Thanks,


#4

Guess it would help if I had the lesson in front of me. Try puts i * 5.

... or read through the OP. My bad.


#5

OMG! that worked. Thank you so much!


#6

puts i * 5 works, thank you!


#8

This is a very poor question on Code Academy's part since we do not know the syntax for blocks well enough yet to answer even this simpe problem. None of the previous syntax with .each work here.
Also the question says it prints 5 5 5 5 5, but it doesn't.

It prints:
5
5
5
5
5
5

This is confusing.

To be clear the entire code is:

[1, 2, 3, 4, 5].each { |i| puts i * 5 }

There is no way I could have figured this out on my own, so thanks to @mtf for the help, and @hdcooper for asking this question.


#9