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
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.
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
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 i