--000e0cd4036c79cc32047ab7d3e3
Content-Type: text/plain; charset=ISO-8859-1

On Mon, Dec 14, 2009 at 3:23 PM, Roger Pack <rogerpack2005 / gmail.com> wrote:

> >> "abcd"[0..2]  ggg'
> "ggg"
>
> What is going on here, anybody have any ideas?
>

Ruby lets you invoke #[] n literals.  They then go immediately out of
scope and will be garbage collected, I assume.  #[] ill 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--