From: Eric Christopherson Date: 2012-05-23T00:23:51+09:00 Subject: Re: Opinion on String#camelcase On Tue, May 22, 2012 at 9:51 AM, Intransition wrote: > Recently I adjusted Ruby Facets String#camelcase method to leave the first > character of the string alone. Previously it would upcase the first > character by default. I never could decide is downcase or upcase should the > default, so that's why I ultimately settled on doing neither and leaving it > to the end-developer to handle. To which end I also added #uppercase and > #lowercase methods to alter just the first character. So one can do: > >   "foo_man".camelcase                  #=> 'fooMan" >   "foo_man".uppercase.camelcase  #=> 'FooMan" >   "Foo_man".lowercase.camelcase  #=> 'fooMan" It might be painful, but I'd change the names `uppercase` and `lowercase` to be more specific about just affecting the first character. With the current names it's ambiguous whether they convert all the letters, just the first one, or something else. (I found myself wondering why you didn't just use String#capitalize instead of creating your own uppercase method, but then I found #capitalize has the surprising [to me] feature of lowercasing all non-initial letters... so the standard library is not immune to this kind of naming ambiguity.) > > Of course, there is still the optional argument too: > >   "foo_man".camelcase(:upper)  #=> 'FooMan" >   "Foo_man".camelcase(:lower)  #=> 'fooMan" > > Does this approach make sense to others? Sounds good to me. > > I know the change probably pissed off a few people, as they had to go back > and fix some lines of code. But I think the new approach is for the better. > Yet, just to be sure I want to solicit opinions. Do you agree with this > change, or do you think defaulting to either upper or lower case was really > the proper approach? > > I know I should have done this earlier, but better late then never.