Ternary if and ~ does not work quite well
Andre via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Oct 11 22:19:38 PDT 2015
Hi,
I am not sure, whether the output of following coding is correct:
import std.stdio;
void main()
{
writeln("foo "~ true ? "bar" : "baz");
writeln("foo "~ false ? "bar" : "baz");
// assert("foo "~ true ? "bar" : "baz" == "foo bar"); does not
compile
}
Output:
> bar
> bar
I would expect the output:
> foo bar
> foo baz
Also I would expect the assertion to compile.
Kind regards
André
More information about the Digitalmars-d-learn
mailing list