On Friday, 17 February 2017 at 20:06:19 UTC, berni wrote:
I wonder if it's possible to do something like this:
import std.stdio;
void main(string[] args)
{
if (args[1]=="a")
{
write("A");
scope (exit) write("B");
}
write("C");
}
I expected the output to be ACB not ABC. I understand, that the
scope ends at the end of the if, but I wonder, if it's possible
to have a "conditional scope" or something like this.
I found a workaround using "finally", but anyway I'm curious.
could be useful to have something like
scope(final)
that would be the "final scope"