On 06/16/2017 05:02 PM, Jolly James wrote:

>>> I am looking for something similar to C#'s generic list.

> Thx, but I do not need to mix different types (using variant).

If I did well on my quick research, C#'s generic lists are exactly that. :)

> Assuming I use simply an dynamic array, how does one remove an
> specific item?

With std.algorithm.remove:

import std.algorithm;

void main() {
    auto arr = [ 1, 2, 3, 4, 5, 6 ];

    arr = arr.remove(5);            // Removes element at index 3
    assert(arr == [ 1, 2, 3, 4, 5 ]);

    arr = arr.remove!(e => e % 2);  // Removes elements with odd values
    assert(arr == [ 2, 4 ]);
}

Ali

Reply via email to