closures + struct: Error: forward reference to inferred return type of function call

Q. Schroll qs.il.paperinik at gmail.com
Tue Dec 15 19:53:33 UTC 2020


On Monday, 14 December 2020 at 14:39:14 UTC, ddcovery wrote:
> On Monday, 14 December 2020 at 12:22:26 UTC, ddcovery wrote:
>>     int opCmp(Number other){
>>       return _value - other.value;
>>     };
> Correction:
>
> bool opEquals(Number other){
>   return _value == other.value;
> };

You could just give the struct a variable and use that instead of 
the enclosing function's parameter:

https://run.dlang.io/is/4Lqf15

Then, the struct can actually be static.


More information about the Digitalmars-d-learn mailing list