Chaining std.algorithm functions

DH arcticuno at gmail.com
Thu Apr 12 10:00:35 PDT 2012


Hi. I was wondering why the following works:

     filter!(a => a % 2 == 0)(map!(a => a + 1)([1,2,3,4,5]))

but the following does not:

     [1,2,3,4,5]
         .map!(a => a + 1)()
         .filter!(a => a % 2 == 0)()

...giving me the error `Error: no property 'filter' for type 
'Result'`

The dot syntax works fine if I'm just doing one map/filter/etc., 
though. Is
there a better way to do chaining like this? Am I 
misunderstanding how the dot
syntax sugar works or how map/filter/etc work in D? I'd prefer 
not to use the
first style as it can get a bit unwieldy...

Thanks for your time!
~DH



More information about the Digitalmars-d-learn mailing list