Nagging question related to 18. Blocks


#1



I keep wondering why Ruby includes the last line of the output in 18. Blocks:

The output (to the console) is:

1
4
9
16
25
[1, 2, 3, 4, 5]

Which part of the code is telling Ruby to include [1, 2, 3, 4, 5] at the end?


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

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


#2

It's not ruby doing that, it's codecademy, ignore it and just mind the parts that your own code is outputting.


#3

Aha! Good to know that. Thank you for your explanation Ionatan! :blush: