set multiple elements at the same time : Range Index « Array « Ruby






set multiple elements at the same time


a[1..3] = ["a", "b", "c"]
puts a.inspect

 

Related examples in the same category

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