use ranges as array indices to select multiple elements at the same time: : Range Index « Array « Ruby






use ranges as array indices to select multiple elements at the same time:

a = [2, 4, 6, 8, 10, 12]
puts a[1..3].inspect

 

Related examples in the same category

1.set multiple elements at the same time