From: Gerente de Sistemas Date: 2012-05-23T04:18:39+09:00 Subject: Re: Opinion on String#camelcase --bcaec501c52cb12f4704c0a4e2e4 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sorry do no understand: do you want Capitalize or capilatizE? 2012/5/22 Eric Christopherson > 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 leavin= g > it > > to the end-developer to handle. To which end I also added #uppercase an= d > > #lowercase methods to alter just the first character. So one can do: > > > > "foo_man".camelcase #=3D> 'fooMan" > > "foo_man".uppercase.camelcase #=3D> 'FooMan" > > "Foo_man".lowercase.camelcase #=3D> '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) #=3D> 'FooMan" > > "Foo_man".camelcase(:lower) #=3D> '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. > > --=20 Analista de Sistemas *MBA em Log=C3=ADstica:Ger=C3=AAncia Executiva de Transportes, Mobiliza=C3=A7=C3=A3o e Meio Ambiente - GETRAM * * * Provedor de Servi=C3=A7os na InterNet Aten=C3=A7=C3=A3o: Esta carta pode conter anexos no formato *ODF* (*Open Do= cument Format*)/*ABNT* (extens=C3=B5es *odt*, *ods*, *odp*, *odb*, *odg*). Antes d= e pedir os anexos em outro formato, voc=C3=AA pode instalar gratuita e livrem= ente o *LibreOffice* ou o seguinte Aditivo para Microsoft Office (R) ( http://www.sun.com/software/star/odf_plugin/get.jsp),ou aqui . Para compatibilidade com as normas *ISO* sugere-se o uso do *LibreOffice* . Para ficar livre dos v=C3=ADrus user www.CentOS.org ou www.FedoraProject.or= g. Converse na rede em: http://chat.mibbit.com Escolha um apelido para voc=C3=AA - nick name - e o canal *#Federalistas*(C= hannel). A senha =C3=A9 "*federalistas*". *CONSOLIDA=C3=87=C3=83O DAS LEIS DAS PROFISS=C3=95ES LIBERAIS * * * --bcaec501c52cb12f4704c0a4e2e4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sorry do no unde= rstand: do you want Capitalize or capilatizE?

2012/5/22 Eric Christopherson <echristopherson@= gmail.com>
On Tue, May 22, 2012 at 9:51 AM, Intransitio= n <transfire@gmail.com> wr= ote:
> Recently I adjusted Ruby Facets String#camelcase method to leave the f= irst
> character of the string alone. Previously it would upcase the first > character by default. I never could decide is downcase or upcase shoul= d the
> default, so that's why I ultimately settled on doing neither and l= eaving it
> to the end-developer to handle. To which end I also added #uppercase a= nd
> #lowercase methods to alter just the first character. So one can do: >
> =C2=A0 "foo_man".camelcase =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0#=3D> 'fooMan"
> =C2=A0 "foo_man".uppercase.camelcase =C2=A0#=3D> 'Foo= Man"
> =C2=A0 "Foo_man".lowercase.camelcase =C2=A0#=3D> 'foo= Man"

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:
>
> =C2=A0 "foo_man".camelcase(:upper) =C2=A0#=3D> 'FooMa= n"
> =C2=A0 "Foo_man".camelcase(:lower) =C2=A0#=3D> 'fooMa= n"
>
> 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 be= tter.
> Yet, just to be sure I want to solicit opinions.=C2=A0Do you agree wit= h this
> change, or do you think defaulting to either upper or lower case was r= eally
> the proper approach?
>
> I know I should have done this earlier, but better late then never.



--
Analista de S= istemas
M= BA em L= og=C3=ADstica: Ger=C3=AAncia Executiva de Transportes, Mobiliza=C3=A7= =C3=A3o e Meio Ambiente - GETRAM

P= rovedor de Servi=C3=A7os na InterNet

Aten=C3=A7=C3=A3o: Esta carta pode co= nter anexos no formato=C2=A0ODF=C2=A0(Open Docu= ment Format)/ABNT=C2=A0(extens=C3=B5es=C2=A0odt,=C2=A0= ods,=C2= =A0odp,= =C2=A0odb,=C2=A0odg). Antes de pedir os anexos em outro formato, voc=C3=AA pode instalar = gratuita e livremente o LibreOffice= ou o seguinte Aditivo para Microsoft Office (R) (<= /font>http://www.sun.com/software/star= /odf_plugin/get.jsp),ou=C2=A0aqui.
Para compatibilidade com as normas ISO sugere-se o uso do LibreOffice= .

Para ficar livre dos v=C3=ADrus user www.CentOS.org=C2=A0ou <= a href=3D"http://www.FedoraProject.org" target=3D"_blank">www.FedoraProject= .org.

Converse na rede em:


Escolha um apelido para voc=C3=AA - nick name - e o canal = #Federalistas (Channel).
A sen= ha =C3=A9 "federalistas".



--bcaec501c52cb12f4704c0a4e2e4--