Change array elements with map! : map « Array « Ruby






Change array elements with map!


array = ['a', 'b', 'c']
array.map! { |x| x.downcase }
p array                               # => ["a", "b", "c"]

 








Related examples in the same category

1.The map method returns a new array instead of a string.
2.Map to uppercase
3.Array map with regular expression