Look at the following code:
In the case provided above, even though b
is greedy, Ruby first attempts to
assign at least one value to
each of the variables.
In this case, one value is
assigned to a, b & c.
Since nothing else is left,
b ends with only 2.
But, since b is using
a *
, that 2 is an array.
Now, let's try the same
thing with more values.
In this example,
Ruby first assigned 1
to a and 2
to b
and
5 to c.
Still, we were
left with 3 & 4
which got assigned to b.