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

Re: uninvited members of associative array



On Sat, Dec 17, 2022 at 1:52 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> Too bad it's not created as the same type as the input.

The input doesn't have a type.  It's the result of a substitution, so
it's just a series of separate words.  Where the words came from is
not remembered.  Consider:

set -A thing new1 new2 "${(@kv)whatever}" new3 new4

What "type" is that?

> Indeed, aren't
> there cases where even declared types are changed?  Like, don't scalars
> convert to integers when you perform arithmetic on them?

That happens in a limited number of circumstances where the type being
assigned-to is known and the conversion is one-to-one.  Note the
importance even then of knowing the type being assigned-to, which is
exactly why you have to declare it before calling "set -A".




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