I have a problem on the exercise 10/12. I should do an array equal to 1through 5.

Is it the good answer : my_array =[1…5] or maybe this one : my_array = [1, 2, 3, 4, 5]

Have you an idea. Thank you for advance for the quick answer.


Your first example will not work as expected. Output will be,


The second example, an array literal, will work as expected.

To assign a range to an array,

numbers = (1..5).to_a
puts numbers             # [1, 2, 3, 4, 5]

Note that in Ruby, a..n includes n in the range. a...n excludes n from the range.


Thank you mtf!

I will try it.

See you.



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