delete an element from an array

spir denis.spir at gmail.com
Sun Oct 24 06:44:08 PDT 2010


On Sun, 24 Oct 2010 09:31:12 -0400
bearophile <bearophileHUGS at lycos.com> wrote:

> Jonathan M Davis:
> 
> > Well, then use indexOf() to get the offset and remove() to remove the element.
> 
> But you must test the result value of indexOf, because it returns -1 (a signed value, probably an integer, not a signed word, so it may give troubles on 64 bit systems) when the item is missing. This is why Python has both a way to remove an item by index and by value.
> 
> Bye,
> bearophile

In my opinion, such non-obvious complications are good reasons to have seemingly trivial operations implemented as builtin routines. (and should throw error in case of failure)


Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



More information about the Digitalmars-d-learn mailing list