* RE: list keys in assoc array.
@ 2003-09-25 17:39 Eric.D.Friedman
0 siblings, 0 replies; 2+ messages in thread
From: Eric.D.Friedman @ 2003-09-25 17:39 UTC (permalink / raw)
To: jprice, zsh-users
Yes ;)
You want the k modifier, in parens within a braced reference to your
associative array: ${(k)assoc_array}
typeset -A frodo
frodo=(foo bar frodo bilbo)
for key in ${(k)frodo};
do
echo $frodo[$key]
done
bar
bilbo
-----Original Message-----
From: Jason Price [mailto:jprice@cyberbuzz.gatech.edu]
Sent: Thursday, September 25, 2003 10:26 AM
To: zsh-users@sunsite.dk
Subject: list keys in assoc array.
I've been poking through the man pages, and I can't find how to get a list
of keys from an associative array. Idealy, I'd like something like:
foreach key in array ; do
if [ array[key] = someval ] ; then
do stuff
fi
done
Am I just being blind in the manpages?
Thanks;
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
* list keys in assoc array.
@ 2003-09-25 17:26 Jason Price
0 siblings, 0 replies; 2+ messages in thread
From: Jason Price @ 2003-09-25 17:26 UTC (permalink / raw)
To: zsh-users
I've been poking through the man pages, and I can't find how to get a list
of keys from an associative array. Idealy, I'd like something like:
foreach key in array ; do
if [ array[key] = someval ] ; then
do stuff
fi
done
Am I just being blind in the manpages?
Thanks;
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-09-25 17:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-25 17:39 list keys in assoc array Eric.D.Friedman
-- strict thread matches above, loose matches on Subject: below --
2003-09-25 17:26 Jason Price
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).