6 Mayıs 2021 Perşembe tarihinde Ulrich Windl < [email protected]> yazdı: > > But why is $# decremented after the first unset? >
Because `x[0]' existed then, and the number of x's members changed with its
removal. `${#x[@]}' doesn't give you the top index of `x', it expands to
the number of elements in `x'. I suspect you don't know that bash arrays
can be sparse. Well, they can be.
$ x=([42]=foo [69]=bar)
$ echo "${#x[@]}"
2
$ echo "${!x[@]}"
42 69
$ echo "${x[@]}"
foo bar
--
Oğuz
