From: Intransition Date: 2012-05-24T04:27:18+09:00 Subject: Re: Opinion on String#camelcase ------=_Part_2790_26554227.1337801236789 Content-Type: multipart/alternative; boundary="----=_Part_2791_22964341.1337801236789" ------=_Part_2791_22964341.1337801236789 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On Tuesday, May 22, 2012 11:23:51 AM UTC-4, Eric Christopherson wrote: > > > 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.) > Yep. that's exactly why I ended up used #uppercase instead. With #capitalize off limits I couldn't think of any better method names at the time. But I agree with you in principle and would be open to any good suggestions. For the record, I asked Matz to change the behavior of #capitalize some time ago, but "his idea of capitalize" (as he put it) was the current one. Personally I think that's too bad because it's easy enough to do `.downcase.capitalize` if that's what one wants. Typical I don't think it is. Couldn't hurt to lets matz know your thoughts on this too. Thanks. ------=_Part_2791_22964341.1337801236789 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit

On Tuesday, May 22, 2012 11:23:51 AM UTC-4, Eric Christopherson wrote:

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.)
 
Yep. that's exactly why I ended up used #uppercase instead. With #capitalize off limits I couldn't think of any better method names at the time. But I agree with you in principle and would be open to any good suggestions.

For the record, I asked Matz to change the behavior of #capitalize some time ago, but "his idea of capitalize" (as he put it) was the current one. Personally I think that's too bad because it's easy enough to do `.downcase.capitalize` if that's what one wants. Typical I don't think it is. Couldn't hurt to lets matz know your thoughts on this too.

Thanks.
------=_Part_2791_22964341.1337801236789-- ------=_Part_2790_26554227.1337801236789--