Alexander Kellett
1/8/2005 10:03:00 PM
On Jan 8, 2005, at 9:53 PM, Trevor Andrade wrote:
> I think was a bit ambiguous in my email so let me make myself clear.
> The
> term multiple assignment is used in two situation or at least I use it
> in
> two situations. In one situation a variable is assigned to and then
> assigned to again. In the other situation, two variable are assigned
> to at
> the same time. Both these situations are called multiple assignment.
> I am
> referring to the first situation. I believe you are referring to the
> second. I have no problem with the second situation. It is the first
> that
> I believe is unnecessary. Unless I am missing something and the two
> kinds
> of multiple assignment are some how related.
i can't really explain.
but it just feels right.
maybe the ruth/ast will help u see why:
irb(main):003:0> Ruby.parse 'def mult_ret; return 1, 5; end'
=> Def[:mult_ret, [], Return[ArrayLiteral[[IntegerLiteral[1],
IntegerLiteral[5]]]]]
and
irb(main):007:0> Ruby.parse 'a, b = nil, nil'
=> Masgn[ArrayLiteral[[LocalAssign[:a, nil], LocalAssign[:b, nil]]],
nil, ArrayLiteral[[NilLiteral[], NilLiteral[]]]]
(notice the use of ArrayLiteral as return and ArrayLiteral in
multi-assign)
for a more concrete and useful example.
consider this:
a, b = b, a
Alex