The map method returns a new array instead of a string. : map « Array « Ruby






The map method returns a new array instead of a string.


month_a = %w[ nil jan feb mar apr may jun jul aug sep oct nov dec ]
month_a_2007 = month_a.map { |e| e.capitalize + " 2007" }

 








Related examples in the same category

1.Change array elements with map!
2.Map to uppercase
3.Array map with regular expression