From: dblack@... Date: 2006-04-08T22:04:22+09:00 Subject: Re: Ruby string Hi -- On Sat, 8 Apr 2006, Peter wrote: > string = "this is a String" > string.capitalize = "This is a string" > That works but changes my capital "a String" to lowercase. > > I only want to capitalize first letter. > So I try" > string[0..0].capitalize > irb => "T" > OK > string[0..0].capitalize! > irb => "T" > irb string > irb => "this is a string" > > I am a noob but I don't get that. > Where is my capitalised first letter. What you've done is to create a new string, consisting of the single character 't'. Then you've done an in-place capitalize on that string; then you've discarded it :-) I can't think of a better way to do this than what's already been posted, though it really does feel like there should be. 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