Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Associative Arrays don't work
- X-seq: zsh-users 10176
- From: DervishD <zsh@xxxxxxxxxxxx>
- To: Com MN PG P E B Consultant 3 <mn-pg-p-e-b-consultant-3.com@xxxxxxxxxxx>
- Subject: Re: Associative Arrays don't work
- Date: Mon, 24 Apr 2006 10:48:44 +0200
- Cc: zsh-users Mailinglist <zsh-users@xxxxxxxxxx>
- In-reply-to: <6F0CB04509C11D46A54232E852E390AC013D96E9@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mail-followup-to: Com MN PG P E B Consultant 3 <mn-pg-p-e-b-consultant-3.com@xxxxxxxxxxx>, zsh-users Mailinglist <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Organization: DervishD
- References: <6F0CB04509C11D46A54232E852E390AC013D96E9@xxxxxxxxxxxxxxxxxxxxxxxxxx>
Hi Ronald :)
* Com MN PG P E B Consultant 3 <mn-pg-p-e-b-consultant-3.com@xxxxxxxxxxx> dixit:
> $ zz=() # According to zsh doc, should created any array, including associative
I can't find where is that said. On the contrary, what I've found
is this:
"Associative arrays _must_ be declared before assignment..."
> $ 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
Of course, "g" is zero, so you get the zeroth element from the
array you just vivified.
> $ zz[g]=5 # Set element g to 5
> $ echo $zz[f] # Request element f. We should get 4, but we get 5
Idem. You assigned to element zero, so you modified it.
Try this:
$ typeset -A zz
$ zz[f]=4
$ zz[g]=5
$ print "Here goes zz[f] =>$zz[f] and here zz[g] =>$zz[g]"
Here goes zz[f] =>4 and here zz[g] =>5
Hope this helps ;) (tested under 4.2.6, BTW)
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to... RAmen!
Messages sorted by:
Reverse Date,
Date,
Thread,
Author