you can convert an array on the fly using the collect method : collect Array Ruby


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