Aldo Giambelluca
2014-May-25 18:37 UTC
#upcase_first_char method to upcase only the first letter, not the rest
Hi All, I recently had to upcase the first char and gave #capitalize a try but I discovered that it downcase everything else. This is not necessary good when dealing with strings containing names or acronyms E.g. if I've a string like this "my name is Aldo and I like BBQ" and I use #capitalize it will downcase "I", "Aldo" and "BBQ" which could not be what I want. What about a method which upcase the first characher leaving the rest untouched? We have #titleize and #capitalize and I think we should also have a method to upcase just the first letter. I know I could just manually add something in my app (and I did) but I think a method like this would be very useful (see http://stackoverflow.com/q/2646709 for example). I added a method called #upcase_first_char and made a pull request: https://github.com/rails/rails/pull/15319 Apologies if I did this before asking in the ML, first non-doc pull request here :) Aldo -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.