Ternary if and ~ does not work quite well
    anonymous via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Sun Oct 11 22:34:11 PDT 2015
    
    
  
On Monday 12 October 2015 07:23, Rikki Cattermole wrote:
> On 12/10/15 6:19 PM, Andre wrote:
[...]
>>      // assert("foo "~ true ? "bar" : "baz" == "foo bar"); does not 
compile
[...]
> 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!
It's `assert(("foo "~ true) ? ("bar") : ("baz" == "foo bar"));` though.
    
    
More information about the Digitalmars-d-learn
mailing list