Trouble checking for null-ness

Bahman Movaqar via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 25 05:37:18 PDT 2016


Suppose I have the following function:

    public auto max(alias comp, Range)(Range r)
    in {
      assert(r !is null && !r.empty);
    }
    body {
      // ...
    }

When the function after a series of chained `map` operations, I get the
following error:

    Error: incompatible types for ((r) !is (null)):
'MapResult!(__lambda2, SInvoiceLine[])' and 'typeof(null)'

Of course if I remove `r !is null` from the `in` block, everything will
work.  But I'm curious; how can I check for a `null` in this case?

Thanks,
-- 
Bahman


More information about the Digitalmars-d-learn mailing list