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