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
  • delegates that return void + ... Joshua Hodkinson via Digitalmars-d-learn

Reply via email to