Puzzled by this behavior
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Tue May 31 18:59:39 UTC 2022
On Tuesday, 31 May 2022 at 18:30:12 UTC, Don Allen wrote:
> static methods?). Without understanding the reason for this
> choice, I must say I find it quite odd.
The reason is that D is more evolved than designed. There is no
reason for mixing declaration order with checking for
initialization before use.
This works with lambdas:
```
void main()
{
int i;
void delegate() foo;
auto bar = (){
writeln("Hello world");
if(++i < 10) foo();
};
foo = (){ bar(); };
foo();
}
```
More information about the Digitalmars-d
mailing list