Do you have a better way to remove element from a array?
Tobias Pankrath via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Feb 5 05:29:29 PST 2015
On Thursday, 5 February 2015 at 13:25:37 UTC, FrankLike wrote:
> Now I can remove element from a array:
>
> module removeOne;
> import std.stdio;
> import std.array;
> import std.algorithm;
>
> void main()
> {
> int[] aa =[1,2,3,4,5];
>
> aa = aa[0..2] ~aa[3..$];
> writeln(aa); //ok
> remove(aa,1);
> writeln(aa);//get error result
> }
>
> You will found the error result,why?
>
> Thank you.
Works as designed:
http://dlang.org/phobos/std_algorithm.html#.remove
More information about the Digitalmars-d-learn
mailing list