Explain function syntax
kdevel
kdevel at vogtner.de
Thu Sep 18 11:04:48 UTC 2025
On Wednesday, 17 September 2025 at 22:16:50 UTC, Brother Bill
wrote:
> return value => increment + value; // ← compilation ERROR
```d
void main()
{
auto calc = makeCalculator;
writeln (calc (1));
}
alias Calculator = int function(int);
Calculator makeCalculator()
{
enum increment = 10; // must not be a stack var
return value => increment + value;
}
import std.stdio;
```
Compiles and prints 11.
More information about the Digitalmars-d-learn
mailing list