scope guard question
Arjan
arjan at ask.me.to
Mon Jun 29 22:31:12 UTC 2020
```
void main()
{
import std.stdio;
auto f = (){
string[] t;
{ // inner scope
t ~= "hello";
scope( exit ) t ~= "world";
} // inner scope exit
return t;
};
f().writeln; // ["hello", "world"]
}
```
removing the inner scope in f() gives ["hello"]
So when no inner scope is present, the scope exit 'runs' after
the return? Is that indeed expected behavior according to the
specification?
More information about the Digitalmars-d-learn
mailing list