October 13, 2020
How to specify which parameters a function that is received as an argument should receive?

Example:

import std;

void myfun(int n){
    writeln(n);
}


void test(lazy void delegate() fun) // how specify that "fun" may receive int ?
{
    fun(int);
}

test({myfun;});
October 13, 2020
On Tuesday, 13 October 2020 at 09:02:04 UTC, Marcone wrote:
> How to specify which parameters a function that is received as an argument should receive?
>
> Example:
>
> import std;
>
> void myfun(int n){
>     writeln(n);
> }
>
>
> void test(lazy void delegate() fun) // how specify that "fun" may receive int ?
> {
>     fun(int);
> }
>
> test({myfun;});

You need to change signature of your function to:
```
void test(lazy void delegate(int) fun)
///                          ^ this is all you need :D
```
And then pass some value to `fun`
Working example: https://run.dlang.io/is/B9bbVl