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)

Posted on April 1, 2009 at 10:17 am by Jordan Carter · Permalink
In: Uncategorized · Tagged with: , , , ,

2 Responses

  1. Written by Chris
    on April 5, 2009 at 11:06 pm
    Permalink

    looks like you’ve got the html code showing instead of just an ampersand..

  2. Written by Tomraider
    on September 9, 2009 at 4:29 pm
    Permalink

    Try using .titleize instead of capitalize.

    >> “new plymouth”.capitalize
    => “New plymouth”
    >> “new plymouth”.titleize
    => “New Plymouth”

Leave a Reply