Correct way to populate an Array with a Range in Ruby

ruby, syntax

Solution

You can create an array with a range using splat,

>> a=*(1..10)
=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

using `Kernel` `Array` method,

Array (1..10)
=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

or using to_a

(1..10).to_a
=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Problem

I am working through a book which gives examples of Ranges being converted to equivalent arrays using their "to_a" methods When i run the code in irb I get the following warning ``` warning: default `to_a' will be obsolete ``` What is the the correct alternative to using to_a? are there alternate ways to populate an array with a Range?

Original source

Related problems