Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Typeset with array
On Jun 23, 7:52pm, Mikael Magnusson wrote:
}
} This isn't really related to this series, but I noticed it now for the
} first time; what's the deal with the space at the end of associative
} arrays in typeset -p output?
With a normal array, the number of elements is known, so you know when
you've reached the last one and can skip printing the space after it.
When traversing a hash table, you don't know if you've reached the last
element until you've passed it; it's more straighforward to print out
("%s %s ", key, value) for every element than to keep track of whether
you are past the first element but not yet at the last one.
If I were going to "fix" it for no reason other than the consistency,
I'd simply add MORE spaces rather than try to squash that one.
typeset -a a
a=( b )
typeset -A b
b=( b c )
Messages sorted by:
Reverse Date,
Date,
Thread,
Author