Filter a Range Based on a Passed In Variable

Adam D. Ruppe destructionator at gmail.com
Sat Jan 20 19:09:28 UTC 2018


On Saturday, 20 January 2018 at 19:04:06 UTC, jsako wrote:
> I want to be able to filter a range based on a variable known 
> at runtime. Something like this:
>
> [code]
> int id = getFilterID();
>
> auto filteredRange = filter!(a => a.id == 
> id)(rangeToBeFiltered);
>
> [/code]
>
> This doesn't seem to be possible, however as .filter only takes 
> unary predicates. I tried:

That should actually work. What exactly happened when you ran 
that literal code above?


More information about the Digitalmars-d-learn mailing list