From: Matthew Kerwin Date: 2012-05-23T08:01:34+09:00 Subject: Re: Opinion on String#camelcase On 23 May 2012 02:02, Bartosz Dziewoński wrote: > While your change might be more "correct", I can't think of a single > situation in real-world Ruby code where you would need to camelcase > something and keep the first letter small. > > Ruby's constant/module/class names are (by convention) always > UpperCamelCase or UPPERCASE; Ruby's method and variable names are (by > convention) always lower_snake_case. There's no reason to convert > anything to lowerCamelCase, unless you're maybe interfacing with > legacy database or really want to cause yourself trouble by coming up > with different conventions than the usual ones. Not everyone who writes Ruby scripts uses them to generate other Ruby scripts. > Libraries should be optimized for the typical use case. If someone > wants typical camelcasing, they'd just call ".camelcase"; if someone > wants atypical, they'd have to call ".capitalize.camelcase" or > whatever. I agree in principle, but I'd suggest that the default behaviour _explicitly_ leave the first character as-is, with options to force upper- or lower-casedness*. By your assertion (that lowerCamelCase is typical and should be supported by default) I would assume the following would be the same: "foo_bar".camelcase #=> "fooBar" "foo_bar".capitalize.camelcase #=> "fooBar" "FOO"_BAR.camelcase #=> "fooBar" Which suggested that .capitalize should have an optional :none parameter to force it to leave the character as is, if that's what you want. Either way, as long as it's clearly documented. * so back to the original post: yes, I think you've done the right thing. --   Matthew Kerwin, B.Sc (CompSci) (Hons)   http://matthew.kerwin.net.au/   ABN: 59-013-727-651   "You'll never find a programming language that frees   you from the burden of clarifying your ideas." - xkcd