What is "FilterResult" type?

Bahman Movaqar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Sep 9 01:09:14 PDT 2015


On Wednesday, 9 September 2015 at 07:59:57 UTC, Sebastiaan Koppe 
wrote:
> What is going wrong is that the types aren't the same. That is, 
> the type of the seed you supplied - `typeof(foobars)` - isn't 
> the type that your function returns - `typeof(acc.filter!...)`.

Alright.  So, `reduce` initial seed is an `array` while the 
output of `filter` is a `FilterResult`.  I suppose it makes sense 
to realise it (`.array`) before passing to the next round.

I was under the impression that `reduce` understands 
`FilterResult` and realises it internally; it doesn't and I was 
wrong.  Though I believe it would have been more intuitive if it 
did.

Thanks for the help.

> `array()` fixes that, no idea why you need `idup()` though.

True --`idup` was not required.  My mistake.




More information about the Digitalmars-d-learn mailing list