From: Tony Arcieri Date: 2009-12-15T07:30:54+09:00 Subject: Re: what does this do? --000e0cd4036c79cc32047ab7d3e3 Content-Type: text/plain; charset=ISO-8859-1 On Mon, Dec 14, 2009 at 3:23 PM, Roger Pack wrote: > >> "abcd"[0..2] = 'ggg' > => "ggg" > > What is going on here, anybody have any ideas? > Ruby lets you invoke #[]= on literals. They then go immediately out of scope and will be garbage collected, I assume. #[]= will always return the value on the RHS. Perhaps this clears things up: => "abcd" >> x[0..2] = 'ggg' => "ggg" >> x => "gggd" So that's what would happen if you used a variable instead of a literal. What you're doing isn't much different from: {:foo => 42}[:foo] = 'ggg' -- Tony Arcieri Medioh! A Kudelski Brand --000e0cd4036c79cc32047ab7d3e3--