From: Josh Cheek Date: 2009-12-15T07:32:15+09:00 Subject: Re: what does this do? --0016369206ff58d631047ab7d8dc Content-Type: text/plain; charset=ISO-8859-1 On Mon, Dec 14, 2009 at 4:23 PM, Roger Pack wrote: > >> "abcd"[0..2] = 'ggg' > => "ggg" > > What is going on here, anybody have any ideas? > -r > -- > Posted via http://www.ruby-forum.com/. > > var = "abcd" # => "abcd" var[0..2] = 'ggg' # => "ggg" var # => "gggd" It just replaces indexes 0 through 2 with the string "ggg" When you assign it to a variable, it is easier to see. It returned "ggg" in irb (as seen on the second line) because it was assigned through the equal sign, and assignments through equal signs always return whatever the input was. --0016369206ff58d631047ab7d8dc--