After looping through an array, why is the original array returned as output?


In this exercise, we run a simple piece of code shown below. It is supposed to loop through odds and output each element of the array times 2.

The following is the output of the code below:
26101418[1, 3, 5, 7, 9]

I understand the 26101418 piece, but why is the original array printed out in the end?
How can i produce this code so that my output is only 26101418?

odds = [1,3,5,7,9]
odds.each { |x| print x*2 }


I've had the same with some other excercises, e.g. in lesson 5 it prints '1...10' after my list; in lesson 11 it prints '[1,2,3,4,5]' etc.
And then there's a lot of 'nil's being printed (after the expected output) without me understanding why - I expect this to be related to the problem described in this question...?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.