aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2022-03-10 23:12:35 +0100
committerJohannes Stoelp <johannes.stoelp@gmail.com>2022-03-10 23:12:35 +0100
commit33fe4f398c32ab65b71877277712b93f063ed63f (patch)
tree17c085c08891f2d611846109eb88c167b881e99b
parentc57b2b348b2889ddcf94de5ccb147d40734345be (diff)
downloadnotes-33fe4f398c32ab65b71877277712b93f063ed63f.tar.gz
notes-33fe4f398c32ab65b71877277712b93f063ed63f.zip
zsh: key/value prefix for associative arrays
-rw-r--r--src/tools/zsh.md12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/tools/zsh.md b/src/tools/zsh.md
index 7a07a31..ab50644 100644
--- a/src/tools/zsh.md
+++ b/src/tools/zsh.md
@@ -162,6 +162,18 @@ echo ${(L)foo} # aabb
echo ${(U)foo} # AABB
```
+Key/values in associative arrays:
+```zsh
+typeset -A vec; vec[a]='aa'; vec[b]='bb'
+
+echo ${(k)vec} # a b
+echo ${(v)vec} # aa bb
+echo ${(kv)vec} # a aa b bb
+
+# Iterate over key value pairs.
+for k v in ${(kv)vec)}; do ...; done
+```
+
## Argument parsing with `zparseopts`
```zsh