On Tue, 26 Sep 2006 22:06:18 +0900 Newbie <none / none.com> 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