From: Newbie Date: 2006-09-27T01:15:14+09:00 Subject: Re: string#[] That answers what?, which I already knew. I'm asking why? Thomas Adam wrote: >> This must be a common newbie question, but I can't find the answer. >> >> Why does string#[] return an ASCII code, rather than a character? >> >> "abc"[1,2] #-> "bc" >> "abc"[1..2] #-> "bc" >> "abc"[1] #-> 98 > > It tells you why in "ri String#[]": > > `` > Element Reference---If passed a single +Fixnum+, returns the code > of the character at that position. If passed two +Fixnum+ objects, > returns a substring starting at the offset given by the first, and > a length given by the second. If given a range, a substring > containing characters at offsets given by the range is returned. > '' > > -- Thomas Adam >