method

to_a

ruby latest stable - Class: Range

Method not available on this version

This method is only available on newer versions. The first available version (v2_6_3) is shown here.

to_a()
public

Returns an array containing the items in the range.

(1..7).to_a  #=> [1, 2, 3, 4, 5, 6, 7]
(1..).to_a   #=> RangeError: cannot convert endless range to an array