Map and to_proc to easier capitalize array of strings
["auckland", "christchurch", "wellington", "hamilton", "tauranga", "dunedin", "palmerston north", "hastings", "nelson", "napier", "rotorua", "new plymouth", "whangarei", "invercargill", "wanganui", "gisborne"].map(&:capitalize)
Related Posts
Posted on April 1, 2009 at 10:17 am by Jordan Carter · Permalink
In: Uncategorized · Tagged with: blocks, Proc, Rails, Ruby, to_proc
In: Uncategorized · Tagged with: blocks, Proc, Rails, Ruby, to_proc
on April 5, 2009 at 11:06 pm
Permalink
looks like you’ve got the html code showing instead of just an ampersand..
on September 9, 2009 at 4:29 pm
Permalink
Try using .titleize instead of capitalize.
=> “New plymouth”
>> “new plymouth”.titleize
=> “New Plymouth”