On Wed, 2007-10-03 at 01:23 +0900, 7stud -- wrote:
> Arlen Christian Mart Cuss wrote:
> > On Tue, 2007-10-02 at 23:25 +0900, 7stud -- wrote:
> >> Since your example only has one subscript 
> >> expression, it doesn't shed any light on that issue.
> > 
> > It demonstrates, at least, that one subscript op is evaluated
> > left-to-right, thus we expect all of them to be so.
> 
> How do you know the subscript expression wasn't evaluated from right to 
> left?

We'll combine two pieces of information here:

> But anyway, my take on this is that
> 
>   a[0..a.size/2] = a[a.size*2/3..-1] = nil
> 
> is equivalent to:
> 
>   a.[]=(0..a.size/2, a.[]=(a.size*2/3..-1, nil))

And:

> irb(main):001:0> a = [1,2,3,4,5]
> => [1, 2, 3, 4, 5]
> irb(main):002:0> b = 1
> => 1
> irb(main):003:0> a[b] = (b = 10)
> => 10
> irb(main):004:0> a
> => [1, 10, 3, 4, 5]

The first one shows us that our initial double-assignment statement is
decomposed into that there function call. Looking at the second one, we
can also see that it's like this:

a.[]=(b, b = 10)

The second example shows us that `b' in the first parameter must
therefore be evaluated first, before `b = 10' is. We can apply that to
the original example and reason that "0..a.size/2" is evaluated before
"a.[]=(a.size*2/3..-1, nil)".

So, you can conclude that the assignments must be evaluated
left-to-right, because of they way they decompose into functions.

Hope this helps your understanding.

 Arlen