D equivalent for LINQ Where

Python python at python.com
Fri May 2 14:32:04 UTC 2025


I am trying to get some items from a list, but `find` gives me 
unexpected results.

```
import std.stdio;
import std.algorithm;

int[] x = [1, 2, 3, 4, 5, 1, 2, 3];

void main()
{
     auto selection = x.find!(a => a == 2);

     foreach(item;selection)
     {
         writeln(item);
     }
}
```

Output is 2, 3, 4, 5, 1, 2, 3

Basically, I am looking for Where from C#.


More information about the Digitalmars-d-learn mailing list