```Philip Brocoum wrote:
> I think it makes perfect sense. If you are doing multiple assignments,
> do this:
>
> a = b = c = "hi"
>
> But it's pretty cool to be able to do this:
> a, b, c = ["hi", "hello", "wassa"]

The problem is: what is the value of a after:

a, b, c = d

?
The answer is: it depends.  If d is an array, then a becomes d[0],
otherwise a becomes d.  Since you can write:

a, b, c = "hi", "hello", "wassa"

setting each value, and:

a, b, c = "hi"

sets a to "hi" and the other two become nil and since ["hi", "hello",
"wassa"] is a single object, it seems natural to expect that:

a, b, c = ["hi", "hello", "wassa"]

should set a to the array and set b & c to nil, but it doesn't.  Why
should a be set differently in the following cases:

a, b, c = ["hi", "hello", "wassa"]
a, b, c = ["hi", "hello", "wassa"], "hey"

You would expect that each of the following would result in a ending up
with the value of d:

a = d
a, b = d
a, b, c = d

but it doesn't.  If d is an array, then "a = d" sets a to the value of
d, but the others set it to d[0]. If d is not an array, then a takes the
value of d in all cases.  Having an object change implicitly into
something else like this is definitely a gotcha.

Further, consider this example:

a = [[1, 2, 3]]
b, c, d = *a

What is the value of b?  Since the multiple assignment is "equivalent"
to:

b, c, d = [1, 2, 3]

it would seem that the way arrays automagically expand would result in b
becoming 1, but actually b becomes the array [1, 2, 3] meaning that
automagic expansion is not happening.  So even the inconsistency is
inconsistent!

The semantics of assignment should not change just because the class of
something on the rhs changes.
--
Posted via http://www.ruby-forum.com/.

```