scope with if
berni via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Feb 17 12:06:19 PST 2017
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.
More information about the Digitalmars-d-learn
mailing list