zsh-workers
 help / color / mirror / code / Atom feed
* array-=$value ?
@ 2006-08-20  7:01 Matthias Kopfermann
  2006-08-20 13:28 ` Matthias Kopfermann
  0 siblings, 1 reply; 3+ messages in thread
From: Matthias Kopfermann @ 2006-08-20  7:01 UTC (permalink / raw)
  To: Zsh-Workers

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?

                Matthias


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: array-=$value ?
  2006-08-20  7:01 array-=$value ? Matthias Kopfermann
@ 2006-08-20 13:28 ` Matthias Kopfermann
  2006-08-20 16:16   ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Matthias Kopfermann @ 2006-08-20 13:28 UTC (permalink / raw)
  To: Zsh-Workers

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: array-=$value ?
  2006-08-20 13:28 ` Matthias Kopfermann
@ 2006-08-20 16:16   ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2006-08-20 16:16 UTC (permalink / raw)
  To: Zsh-Workers

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-08-20 16:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-20  7:01 array-=$value ? Matthias Kopfermann
2006-08-20 13:28 ` Matthias Kopfermann
2006-08-20 16:16   ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).