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

Re: uninvited members of associative array



Bart already addressed the actual issue, so I'll just touch on this:

On Sat, Dec 17, 2022, at 3:31 PM, Ray Andrews wrote:
> I don't understand 
> the difference between '-A' and '+A' maybe that's part of it -- the 
> global array might not be overwritten cleanly or something.

If the array is already populated, "set +A" only replaces its leading
elements, which means existing elements can get left behind.

	% arr=({a..j}); typeset -p arr
	typeset -a arr=( a b c d e f g h i j )
	% set -A arr {1..5}; typeset -p arr
	typeset -a arr=( 1 2 3 4 5 )
	% set +A arr x y z; typeset -p arr
	typeset -a arr=( x y z 4 5 )

I'm not sure why you brought this up.  Are you using "set +A"
somewhere?

-- 
vq




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