Using the clone method is the actual way of copying between arrays. : clone « Array « Ruby






Using the clone method is the actual way of copying between arrays.


a = [1,2,3,4,5]
b = a.clone
puts b

a = [1,2,3,4,5]
b = a.collect{|x| 10*x}
puts b

 








Related examples in the same category