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

Re: array-=$value ?

On Aug 20,  3:28pm, Matthias Kopfermann wrote:
} Am Sonntag, dem 20. August 2006 um 09:01 Uhr, Matthias Kopfermann:
} > A question i was not able to answer myself:
} > array=( a b c d e)
} > array+=f # works
} > array-=a # does not work, but why exactly?
} Ah, I guess, it's because then it should really delete the
} last value and then in this case -=a would do something non
} obvious to stay analogue to +=d.

Right.  As another example, suppose the element "a" appears more than
once in the array.  Should -= mean array[(r)a]=() or array[(R)a]=() or
array=(${array:#a}) ?

And what would array-=(e a c) mean?  Most obvious would be that it maps
the operator over the argument, I guess, but that's not the only choice.
Have you noticed that array[2]+=(x y z) splices the new elements into
the array between positions 2 and 3?  Describe array[2]-=(x y z).

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