Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: uninvited members of associative array



On Sat, Dec 17, 2022 at 12:31 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> I don't understand
> the difference between '-A' and '+A' maybe that's part of it

The difficulty here (unfortunately) is that "-A" doesn't always mean
the same thing.

"typeset -a" means a normal array and "typeset -A" (or "local" in
either case) means an associative array.

"set -a" was taken (short for "setopt ALL_EXPORT" from sh
compatibility) so "set -A" means "assign to array" where "array" may
be either normal or associative.  But if the array doesn't already
exist, it is implicitly created as a normal array.  So you must
pre-declare names with "local -A" or similar if you want them treated
as associative.




Messages sorted by: Reverse Date, Date, Thread, Author