Mega Code Archive

 
Categories / Ruby / Array
 

You can convert an array on the fly using the collect method

[1, 2, 3, 4].collect { |element| element * 2 }