From: Josh Cheek Date: 2010-07-14T06:54:30+09:00 Subject: Re: What does this do? --0016e659f8e6bb4bec048b4be95d Content-Type: text/plain; charset=ISO-8859-1 On Tue, Jul 13, 2010 at 4:26 PM, Abder-Rahman Ali < abder.rahman.ali@gmail.com> wrote: > I have this portion of code from "Why's poignant guide to Ruby" book. > > str = "A string is a long shelf of letters and spaces" # Nice definition > :-) > puts str[0..-1] > puts str[1..-2] > > I just want to ask. Does the preceding code REMOVE what is BETWEEN the > range? I just concluded that from the result I get and want to make > sure. > > Thanks. > -- > Posted via http://www.ruby-forum.com/. > > I'm not really sure what you're asking, but I think that it is probably answered by the docs: http://ruby-doc.org/core/classes/String.html#M000771 str[range] => new str or nil If given a range, a substring containing characters at offsets given by the range is returned. In all three cases, if an offset is negative, it is counted from the end of *str*. --0016e659f8e6bb4bec048b4be95d--