I wanted to use a map that looked like this: declare -A switches=([num]=(one two three)), where '(one two three)' is an associated list. Ideally, I could access it like other arrays: for types in ${switches[num][@]}; do... or switches[num]=(one two three) #gives: -bash: switches[num]: cannot assign list to array member or echo ${switches[num][0]} (="one").
I defaulted to going around it by making it a string, like: switches[num]="one|two|three" or switches[num]="(one two three)" but why? It seems obvious that bash knows what I'm trying to do, so why not just do it? Some nested constructs seem to work: > b=(1 2 3) > a=(4 5 6) > echo ${a[${b[1]}]} 6 but more often than not, they don't. Is there a reason to disallow such?