Map to uppercase : map « Array « Ruby






Map to uppercase


words = %w[hello world]                 # Another collection
upper = words.map {|x| x.upcase }       # Map to uppercase

 








Related examples in the same category

1.The map method returns a new array instead of a string.
2.Change array elements with map!
3.Array map with regular expression