Filter and Map's weird return types cause frustration...

bearophile bearophileHUGS at lycos.com
Sat Feb 23 01:37:01 PST 2013


Chris Nicholson-Sauls:

> What *would* be nice would be to have "InPlace" variations of 
> these functions for use cases such as yours, in order to re-use 
> resources.
>
> example.filterInPlace!isLongEnough();

Sometimes I'd like some in place operations in Phobos.

To remove duplicate items from a mutable array of sortable items:

data.length -= data.sort().uniq().copy(data).length;


or to just remove the item "5" from an array of ints, it's not 
hard to miss the necessary self-assignment:

data = data.delete(5);

Bye,
bearophile


More information about the Digitalmars-d mailing list