scope with if

berni via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Feb 18 12:31:20 PST 2017


Just a note - I found something, that works:

>import std.stdio;
>
>void main(string[] args)
>{
>    immutable cond = args[1]=="a";
>    if (cond) write("A");
>    scope (exit) if (cond) write("B");
>
>    write("C");
>}

I'm using the immutable variable to avoid, that the condition 
changes later.


More information about the Digitalmars-d-learn mailing list