Ruby - overriding/enabling multiple assignment (e.g. `a, b, c = d, e, f`)
- by nicholaides
In ruby, you can do this:
d = [1, 2, 3]
a, b, c = d
a, b, and c, will receive the values 1, 2, and 3, respectively.
d, in this case in an Array and ruby knows to assign it's contents to a, b, and c. But, if d were a Fixnum, for example, only a would be assigned to the value of d while b and c would be assigned nil.
What properties of d allow it to be used for multiple assignment? In my exploring so far, I've only been able to make instances of subclasses of Array behave in this way.