What is "FilterResult" type?

Bahman Movaqar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 8 04:08:57 PDT 2015


On Tuesday, 8 September 2015 at 10:08:03 UTC, cym13 wrote:
> Filter is a template and returns a FilterResult range which is 
> used to lazily compute the result. This behaviour is the same 
> for map and the majority of functions in std.algorithm.

Ah...now it makes sense why use a proxy to the results.

> It is an input range really (ie: it has front, popFront and 
> empty). You can chain it just like any other range with other 
> functions and normally don't have to know the exact type (which 
> would be complicated since it is a templated thing).

I agree.  Some types are better left unspecified; like some 300+ 
characters long type signatures one would get from a generic 
Scala function :-D

However, I have made this a strict practice of mine to specify 
the full signature of my public API.  I suppose, if I want to be 
pedantic, I have to realise the lazy value first and pass the 
resulting array out.  Is this correct?

> To store it in a variable if you don't know the exact type you 
> can use auto to use type deduction.

True.

> Example:

Great.  The usage is crystal clear to me now.

> If you want more precise documentation the best is to look to 
> the source code (/usr/include/dlang/dmd/std/algorithm/iteration 
> if you are on linux).

Thanks for the help and pointers.



More information about the Digitalmars-d-learn mailing list