bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] Can a key in a array be deleted while the array is iterat


From: Andrew J. Schorr
Subject: Re: [bug-gawk] Can a key in a array be deleted while the array is iterated?
Date: Tue, 3 Jan 2017 11:37:56 -0500
User-agent: Mutt/1.5.23 (2014-03-12)

On Tue, Jan 03, 2017 at 03:56:16PM +0100, Manuel Collado wrote:
> Well, it seems safe to modify the current iterated array element. But
> modifying array elements other then the current one may be troublesome.
> 
> In this particular case, the original code could be modified by iterating
> over the second (unchanged) array instead of the first (been modified) one.
> As follows:
> 
> function arrkeyintersect(x1, x2,    k) {
>     for(k in x2) {
>         delete x1[k]
>         }
>     }
> }

It's not clear to me. Can you please elaborate on why this code is dangerous?

Thanks,
Andy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]