Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
RE: Associative Arrays don't work
- X-seq: zsh-users 10177
- From: "Com MN PG P E B Consultant 3" <mn-pg-p-e-b-consultant-3.com@xxxxxxxxxxx>
- To: "DervishD" <zsh@xxxxxxxxxxxx>
- Subject: RE: Associative Arrays don't work
- Date: Mon, 24 Apr 2006 11:28:00 +0200
- Cc: "zsh-users Mailinglist" <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Thread-index: AcZnfByQM3/masSMSTyjgGzCU1rzbgAAyqBQ
- Thread-topic: Associative Arrays don't work
> * 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.
Having reread http://zsh.sunsite.dk/Doc/Release/zsh_14.html#SEC72 again,
I now see
that we have two contradicting statements about this. The first one is
exactly
like you said:
>
On the contrary, what I've found
> is this:
>
> "Associative arrays _must_ be declared before assignment..."
The second information, further down this section, says:
"To create an empty array (including associative arrays), use one of:
set -A name
name=()"
When I saw the "use one of", I was happy enough to not read the whole
section verbatim.
Hence, I had chosen the "name=()" form, believing that it would be
sufficient.
I now see that I has mistakingly believed that creation of an
associative array could
be done without declaring 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)
It does, indeed. Thank you very much!
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