18. Blocks Attn: @zystvan


Please help...am lost!

Here is my code:

my_array = [1, 2, 3, 4, 5]

users.each do |user|
'puts' user.name

Here is what happens when I try to save & submit:

"Oops, try again. It looks like your syntax isn't quite right. Check the Hint if you need help!"

Thankyou in advance......Sam!


Hi Sam,

I have no knowledge of Ruby and I understand that you want zystvan to help you, so I won't try to solve this, but I'm just letting you know I have invited @zystvan and he will probably reply shortly.


Hey, @samg2015, just follow the instructions.

"Add a block after .each that multiplies each item by itself and puts the result to the console."

You've successfully added a block after users.each that should do puts user.name. In this excercise however there's no user and you have to work with my_array in a similar fashion. Try adding do block that "multiplies each item by itself and then puts the result to the console"

If the next piece of code is correct in the context of user, try and use the structure to iterate over my_array and multiply the items.

users.each do |user|
  puts user.name

Don't hesitate to ask follow-up questions!


Hi thankyou, much appreciated! :wink:


@jibblyj thanks for inviting me into this topic :)

@samg2015, you'll need to remove the my_array.each line, and replace users with my_array on line 4. You might also want to pick a more appropriate incrementer thing than user, maybe something like number instead?


@zystvan thankyou for your help & advice! I revised my code...and followed your advice!

my_array = [1, 2, 3, 4, 5]

my_array.each do |n| n = n * n
puts n

I have finally passed this level! Again many thanks! :wink:


Hi thanks to yours and zystvan's advice I have managed to pass the level!

So thankyou, much appreciated!

Sam :smile: