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

Associative Arrays don't work



zsh is supposed to have associative arrays, but they don't work for me.
Here an example:

$ zz=()       # According to zsh doc, should created any array,
including associative 
$ zz[f]=4     # Set element f to 4
$ echo $zz[g] # Request element g (not f). Element g should not be
there, but we get 4
4
$ zz[g]=5     # Set element g to 5
$ echo $zz[f] # Request element f. We should get 4, but we get 5
5

Hence, "f" and "g" are treated equivalent - not what I would expect from
an associative array.

I googled a bit in the zsh mailing list archive and found a posting from
1998 which claimed
that one should use the -H option to create an associative array. Though
this seems to contradict
the documentation for zsh, I tried the example posted there - and the
result was even more 
bizarre:

$ typeset -H assoc
$ assoc[bread]=butter
$ assoc[toast]=jam
$ echo $assoc
jamutter
$ echo $assoc[bread]
j

I tried these examples with the two zsh versions I have access to -
4.0.7 and 4.2.4 - and got
the same result on both.

Ronald
-- 
Ronald Fischer (phone +49-89-63676431)
mailto:mn-pg-p-e-b-consultant-3.com@xxxxxxxxxxx



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