Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
How to iterate over an array of associative arrays
- X-seq: zsh-users 17867
- From: Thorsten Kampe <thorsten@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: How to iterate over an array of associative arrays
- Date: Sun, 14 Jul 2013 14:35:25 +0200
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
Hi,
I'd like to iterate over elements of an array. The elements are
associative arrays. This is my code:
"""
#! /usr/bin/env zsh
emulate -R zsh
setopt nounset
declare -A elem AssocArr1 AssocArr2
AssocArr1=(key value1)
AssocArr2=(key value2)
array=($AssocArr1 $AssocArr2)
for elem in $array
do echo $elem[key]
done
"""
./test.zsh:14: elem[key]: parameter not set
Thorsten
Messages sorted by:
Reverse Date,
Date,
Thread,
Author