Removing elements from dynamic array
Alex Parrill via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Aug 9 08:41:31 PDT 2015
On Sunday, 9 August 2015 at 15:30:32 UTC, Reflexive wrote:
> I wrote import std.algorithm.remove ;, and I dont have any
> longer any error. But, it dont want to remove the item. Here is
> the source, the problem is in the shuffle() method :
>
> ...
Why not just use std.random.shuffle [1]?
import std.random;
void shuffle() {
randomShuffle(this.sabotarray);
}
(Also, this is more of a style opinion, but please don't define
all your variables up front; define them when they're first used.
The other way IMO has too much cognitive load, and you can't use
`auto` in many cases)
[1]: http://dlang.org/phobos/std_random.html#.randomShuffle
More information about the Digitalmars-d-learn
mailing list