On 12/10/15 6:19 PM, Andre wrote:
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é

I read it as:

assert("foo "~ (true ? ("bar") : ("baz" == "foo bar")));

Oh hey look:
/d434/f138.d(6): Error: incompatible types for (("bar") : ("baz" == "foo bar")): 'string' and 'bool'

Compiler agrees!

Reply via email to