From: Jeppe Jakobsen Date: 2006-04-09T06:19:02+09:00 Subject: Re: Ruby string ------=_Part_20067_32350030.1144531138805 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Speaking of alternatives, here is how you also could do it: string[0] =3D string[0].chr.upcase 2006/4/8, dblack@wobblini.net : > > Hi -- > > On Sat, 8 Apr 2006, Peter wrote: > > > I love Ruby but this is cumbersome. > > There are plenty of situations where people want to > > capitalize only the first letter. > > > > By saying: > > string[0,1].capitalize! with ! should read like: > > Capitalize only the first character within string 'string' > > Or is that stupid thinking. > > Its a method on the first character. > > > > Funny. > > But thanks all. > > It may be cumbersome but the alternative you describe would be worse > :-) > > Ruby is pretty strict about left-to-right evaluation. This: > > string[0,1] > > means something: a one-character substring of string. What you do > *with* that substring -- what messages you send it -- is a completely > separate, subsequent transaction. > > > > David > > -- > David A. Black (dblack@wobblini.net) > Ruby Power and Light, LLC (http://www.rubypowerandlight.com) > > "Ruby for Rails" coming in PDF April 15, and in paper May 1! > http://www.manning.com/black > > -- "winners never quit, quitters never win" ------=_Part_20067_32350030.1144531138805--