From: Stefano Crocco Date: 2008-11-25T21:49:10+09:00 Subject: Re: Getting single char from string -- Simpler solution? Alle Tuesday 25 November 2008, sa 125 ha scritto: > Hi - > > I'm trying to get a single char from string, but doing it like this > return the ascii key: > > irb(main):060:0> "hello"[0] > => 104 > > I know this could be accomplished like this: > > irb(main):063:0> "hello".split('')[0] > => "h" > > I'm not too lazy to type, but I was wondering if there's a simpler way I > overlooked. > > Thanks! "hello"[0,1] "hello"[0..0] "hello"[0].chr I hope this helps Stefano