delegates that return void + lambdas
Joshua Hodkinson via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Aug 21 05:15:16 PDT 2017
So I have run across the following issue while working with
delegates and lambdas,
---
struct Struct {
int prop;
}
alias Func = void delegate(ref Struct);
Func func = (ref s) => s.prop += 1;
---
with compiler error `Error: cannot return non-void from function`
I understand that the lambda syntax in this case would be short
for
---
Func func = (ref s) { return s.prop += 1; };
---
But does this mean you can't have lambdas that return void?
Thanks
More information about the Digitalmars-d-learn
mailing list