Convert range to array : Convert to Array « Range « Ruby






Convert range to array


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

 

Related examples in the same category

1.Range class offers a simple way to convert a range into an array with to_a.