why is this cast required?
DanielG
simpletangent at gmail.com
Fri Sep 25 11:14:50 UTC 2026
```d
alias IntFunc = int delegate();
void exec(IntFunc[] funcs) {}
void main()
{
int two() => 2;
exec(
// why do I have to cast to the exact type that exec() already
takes?
cast(IntFunc[])
[
() => 1,
() => two(),
]);
}
```
Without the cast, the error is:
>Error: incompatible types for `(() => 1) : (() => two())`: `int
>function() pure nothrow @nogc @safe` and `int delegate() pure
>nothrow @nogc @safe`
More information about the Digitalmars-d-learn
mailing list