With the Range class, you can also create a range : Range Creation « Range « Ruby






With the Range class, you can also create a range


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

 








Related examples in the same category

1.what are Ranges
2.To create a range, use the .. operator. For example, here's how you might create the range 1 to 4:
3.use the ... operator, which is the same thing except that the final item in the range is omitted
4.Reference to_a from a range
5.Reference to_a from a range in an excluded range
6.Reference to_a from a letter-based range
7.You have to create ranges in ascending sequence
8.Variable based range