Explain function syntax
monkyyy
crazymonkyyy at gmail.com
Wed Sep 17 22:29:22 UTC 2025
On Wednesday, 17 September 2025 at 22:16:50 UTC, Brother Bill
wrote:
> ```
> import std.stdio;
>
> void main()
> {
>
> }
>
> alias Calculator = int function(int);
>
> Calculator makeCalculator()
> {
> int increment = 10;
> return value => increment + value; // ← compilation ERROR
> }
>
> ```
function is almost always wrong you need to be very pure to work
at all and if by chance you ever have a function pointer you can
convert it to a delegate
> What does the second (int) refer to?
it takes an int, just delete the names of the arguments from the
header syntax
More information about the Digitalmars-d-learn
mailing list