On Saturday, 17 June 2017 at 00:28:50 UTC, Ali Çehreli wrote:
On 06/16/2017 05:02 PM, Jolly James wrote:
If I did well on my quick research, C#'s generic lists are
exactly that. :)
C#'s generics allow to specify one datatype T that is used, some
kind of similar to a template. So, a generic list can contain
only elements of type T. That what makes it generic is that M$
had to implement this class only once and now it can be used with
any datatype by simply specifying it ( → List<int> ).
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 ]);
}
Thank you very much :)