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

Re: Variable expansion inside of functions





On Sat, Apr 18, 2026 at 3:58 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
Arrays are parameters.  Everything described in the section on
parameters applies to arrays (and associative arrays / hashes) as
well.  The semantics may differ slightly -- sometimes every array
element is affected individually, sometimes the whole array is
examined.  For $+name (which is shorthand for ${+name}), it's the
whole array.

But the quoted snippet doesn't use bare $+name; it uses $+name[index], which does return the appropriate result for that specific element of the array.

Worth mentioning that $+name is 1 even for an empty array, where $+name[1] in that case will be 0. 
 
--
Mark J. Reed <markjreed@xxxxxxxxx>


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