Explain function syntax
Brother Bill
brotherbill at mail.com
Wed Sep 17 22:16:50 UTC 2025
In the following from Programming in D, page 483, we use function
keyword.
I expect that the first int in
```
int function(int);
```
represents the return value.
What does the second (int) refer to?
Then there is another example with 'delegate' instead of
'function.
```
import std.stdio;
void main()
{
}
alias Calculator = int function(int);
Calculator makeCalculator()
{
int increment = 10;
return value => increment + value; // ← compilation ERROR
}
```
More information about the Digitalmars-d-learn
mailing list