Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: uninvited members of associative array
On Thu, Dec 15, 2022, at 6:48 PM, Ray Andrews wrote:
> I just noticed something. My big array has ten named elements but if I
> print it:
>
> printf "%-20s %s\n" ${(kv)main} > /dev/pts/2
>
> width 90
> window main
> offset 0
> topE 1
> active 1
> 90 main
> bottomE 48
> lastE 196
> hight 48
> 196 48
> List 1
> 0 1
> list List
> 1 48
> currentE 1
>
> ... it all works, however 'elements' 90, 196, 0 and 1 seem to have
> created themselves, I didn't make them.
How are you creating and populating "main"? Can you provide a test
case that the rest of us can actually use? If I just guess the
contents of "main" then I don't see a problem.
% cat foo.zsh
typeset -A main
main=(
active 1
bottomE 48
currentE 1
height 48
lastE 196
list 1
offset 0
topE 1
width 90
window main
)
typeset -p main
printf '%-20s %s\n' ${(kv)main}
% zsh -f foo.zsh
typeset -A main=( [active]=1 [bottomE]=48 [currentE]=1 [height]=48 [lastE]=196 [list]=1 [offset]=0 [topE]=1 [width]=90 [window]=main )
window main
width 90
offset 0
topE 1
height 48
active 1
lastE 196
bottomE 48
list 1
currentE 1
--
vq
Messages sorted by:
Reverse Date,
Date,
Thread,
Author