Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: 3.1.5 - sample associative array implementation
- X-seq: zsh-workers 4603
 
- From: Timothy Writer <Tim.Writer@xxxxxxxxxx>
 
- To: Bruce Stephens <b.stephens@xxxxxxxxx>
 
- Subject: Re: PATCH: 3.1.5 - sample associative array implementation
 
- Date: 11 Nov 1998 15:00:47 -0500
 
- Cc: zsh-workers@xxxxxxxxxxxxxxx (Zsh hackers list)
 
- In-reply-to: Bruce Stephens's message of "11 Nov 1998 14:43:21 +0000"
 
- References: <9811111358.AA51361@xxxxxxxxxxxxxxxxx> <vb1znanvcm.fsf@xxxxxxxxxxxxxxx>
 
Bruce Stephens <b.stephens@xxxxxxxxx> writes:
> Peter Stephenson <pws@xxxxxxxxxxxxxxxxx> writes:
> 
> > This can probably be fixed in a perl-like fasion by adapting
> > setarrvalue(), which should be reasonably painless, though I haven't
> > looked at the details yet.  One question is whether
> >   hash=(key1 val1 key2 val2)
> > replaces the array entirely, or just adds/replaces those elements.  In
> > the former case it's difficult to think of a way of replacing multiple
> > elements at once; maybe another new typeset flag.
> 
> What does ksh93 provide in the way of associative array functionality?
> (I don't have it installed at work, so I can't look it up right not.)
In ksh93 associative arrays are declared using "typeset -A".  They use the
same syntax as indexed arrays, e.g. "foo[bar]=baz"; the text within [] is
subject to variable expansion and whitespace counts.  The following special
notation is used to get all keys:
    "${!arrayname[@]}"
-- 
Tim Writer                                              Tim.Writer@xxxxxxxxxx
FTL Solutions Inc.
Toronto, Ontario, CANADA
Messages sorted by:
Reverse Date,
Date,
Thread,
Author