help-bash
[Top][All Lists]
Advanced

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

Re: How changes in an associate array affect the iteration of its keys?


From: Lawrence Velázquez
Subject: Re: How changes in an associate array affect the iteration of its keys?
Date: Mon, 29 Mar 2021 20:08:03 -0400
User-agent: Cyrus-JMAP/3.5.0-alpha0-273-g8500d2492d-fm-20210323.002-g8500d249

On Mon, Mar 29, 2021, at 8:01 PM, Peng Yu wrote:
> In this example, the changes to the
> associative array x within the loop does not affect the enumeration of
> the keys of x?

Why would it? The parameter expansion "${!x[@]}" is substituted
before the loop is run and cannot be changed after the fact. The
array is not consulted on each iteration.

$ declare -A x=([a]= [b]= [c]=)
$ printf '<%s>' "${!x[@]}"; echo
<c><b><a>

-- 
vq



reply via email to

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