Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Is there an idiom for converting an array to an associative array?
- X-seq: zsh-workers 19384
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: Is there an idiom for converting an array to an associative array?
- Date: Sun, 18 Jan 2004 10:50:38 -0800
- In-reply-to: <87oet2neqo.fsf@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <87vfndnnwe.fsf@xxxxxxxxxxxxxx> <1040116042310.ZM28857@xxxxxxxxxxxxxxxxxxxxxxx> <87oet2neqo.fsf@xxxxxxxxxxxxxx>
On Jan 17, 6:59pm, Matt Armstrong wrote:
> Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> writes:
>
> > typeset "assoc[${^array[@]}]=''"
>
> Thanks, I'll give it a whirl, and then study it for a couple of hours
> to figure out how it works. :-)
Given array=(a b c), X${^array}Y expands to XaY XbY XcY. Does that help?
> > } array=(a b c)
> > } set -A assoc
> >
> > That should be "typeset -A assoc". "set -A" means something entirely
> > different.
>
> I jumped to "To create an empty array (including associative arrays)"
> in the text below:
>
> Associative arrays must be declared before assignment, by using:
>
> typeset -A name
[...]
> To create an empty array (including associative arrays), use one of:
>
> set -A name
"set -A name" is a form of assignment, not a form of declaration. Perhaps
the word "create" was poorly chosen in that bit of documentation (and that
remark is the only reason I'm still sending this to zsh-workers).
Messages sorted by:
Reverse Date,
Date,
Thread,
Author