Ter, 2008-09-09 às 10:10 -0500, Patrick R. Michaud escreveu:
> I think my question can be best understood by example -- what
> does the following produce?
> my @a = 1,2,3,4,5;
> for @a { .say; @a = (); }
The problem actually becomes more evident with
my @a = 1,2,3,4,5;
for @a { .say; @a[5] = 'five' }
because the first code actually replaces the content of the variable @a,
while the second will call .postcircumfix(5), which itself returns a
container which is then STOREd with 'five'.
The basic difference is that in
for @a {...}
we take an iterator that point to the array that is stored at that
moment in @a. If we replace the array stored in the variable @a, that
iterator would still point to the original array.
The second example actually modifies the object stored in the variable
'@a'. And that is a different issue.
daniel