Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: (z) expansion flag do not always return an array



On Mon, Nov 29, 2021 at 4:32 PM Vincent Bernat <bernat@xxxxxxxx> wrote:
>
> Is there an easy way to know if something is an array or a string?
> I am  using subscripting for that but maybe there are better ways.

If you had a parameter, you could use ${(t)foo} or $parameters[foo] to
find its type. However, if you had a parameter you wouldn't have this
problem to begin with.

  foo=(${(z)...})

Here foo is always an array.

Roman.




Messages sorted by: Reverse Date, Date, Thread, Author