filterInPlace

Returns array filtered in-place.

ref
Array
filterInPlace
(
alias pred = "a"
Array
)
(
auto ref Array array
)
if (
isDynamicArray!Array
)

Examples

1 alias isEven = n => n % 2 == 0;
2 auto arr = [1, 2, 2, 2, 3, 3, 4];
3 
4 assert(filterInPlace!isEven(arr) == [2, 2, 2, 4]);
5 // The input array gets modified.
6 assert(arr == [2, 2, 2, 4]);
7 
8 // Can be called with non-lvalues
9 assert(filterInPlace!isEven([1, 2, 2, 2, 3, 3, 4]) == [2, 2, 2, 4]);

Meta