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

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



 ❦ 29 November 2021 17:34 +01, Roman Perepelitsa:

>> 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.

Thanks for the tips!

>   foo=(${(z)...})
>
> Here foo is always an array.

Yes, that's what I have done.
-- 
Let the machine do the dirty work.
            - The Elements of Programming Style (Kernighan & Plauger)




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