Hello!
I'm noticed that something non-obvious is happening with my code
today and i've found that the trouble somewhere close to the
removing items from the dynamic arrays e.i. close to
std.algorithm.remove function in this case.
I wrote a little test example using this function:
module test.app;
import std.stdio: writefln;
import std.algorithm;
int main(string[] args) {
int[] a = [2, 4, 8, 16, 32, 64, 128];
writefln("a before: %s", a);
a.remove(3);
writefln("a after : %s", a);
a.remove(1);
writefln("a after2: %s", a);
return 0;
}
...and got the following output:
a before: [2, 4, 8, 16, 32, 64, 128]
a after : [2, 4, 8, 32, 64, 128, 128]
a after2: [2, 8, 32, 64, 128, 128, 128]
I'm confused.
Please tell me is it normal behavior of this function or is it a
bug?
Maybe i'm doing something wrong?
Maybe i need another "remove" or maybe it's normal to use slicing
to remove array's items (like a = a[0..i] ~ [i+1..$]) ?
Thanx for attention.
P.S. I'm sorry if my english confuses you.