Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Optimization of getarrvalue()
On Mon, Nov 21, 2016 at 4:30 AM, Jun T. <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
>
> Maybe, but I still don't understand, for example, the following:
>
> % a=()
> % nargs "${(@)a[0]}"
> 1
> % a=( foo )
> % nargs "${(@)a[0]}"
> 0
OK, I agree that one is strange. However:
> % a=( foo bar )
> % nargs "${(@)a[3]}"
> 1
> % nargs "${(@)a[3,3]}" # or "${(@)a[3,4]}" "${(@)a[3,5]}" ...
> 0
Two subscripts separated by a comma mean something different than one
subscript. a[3] is a scalar, so adding (@) doesn't matter; a scalar
in double quotes is the empty string. a[3,3] is an array, and an
array with the (@) flag in double quotes resolves to nothing if the
array is empty. The only magic here is the already-magic semantics of
double-quoting "${a[@]}".
> More generally, $a[i,j] with i=$#a+1 is treated specially.
?? It's not treated any differently than i=$#a+N for any N >=0, is it?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author