Ternary if and ~ does not work quite well

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Oct 12 10:07:17 PDT 2015


On Monday 12 October 2015 17:39, TheFlyingFiddle wrote:

> "foo" ~ true
> 
> How does this compile? All i can see is a user trying to append a 
> boolean to a string which is obvously a type error. Or are they 
> converted to ints and then ~ would be a complement operator? In 
> that case.. horror.

char and bool are considered integral types. In `"foo " ~ true`, true is 
converted to a char with a value of 1, i.e. some control character.

I'm not a fan either.


More information about the Digitalmars-d-learn mailing list