bug-gawk
[Top][All Lists]
Advanced

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

[bug-gawk] Can a key in a array be deleted while the array is iterated?


From: Peng Yu
Subject: [bug-gawk] Can a key in a array be deleted while the array is iterated?
Date: Sun, 1 Jan 2017 19:05:29 -0600

Hi,

I made the following function to intersect the keys of x1 and x2. The
results is saved in x1. I am not sure it is OK to change an array
while it is being iterated. Will the function always work? Thanks.

function arrkeyintersect(x1, x2,    k) {
    for(k in x1) {
        if(!(k in x2)) {
            delete x1[k]
        }
    }
}

-- 
Regards,
Peng



reply via email to

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