Reputation: 38960
Hi I have an array of words that I want to do a couple of things to. I want to lowercase each word in the array and I also want to cut off the /n at the end of each string in the array.
How would I do this in ruby if my array was called my_array
?
Upvotes: 0
Views: 3534
Reputation: 14625
my_array.map!{|c| c.downcase.strip}
Docs:
http://ruby-doc.org/core-1.9.3/Array.html#method-i-map-21
http://ruby-doc.org/core-1.9.3/String.html#method-i-strip
Upvotes: 6