Why double not? (!!)

Xinok via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Nov 18 20:54:22 PST 2016


On Saturday, 19 November 2016 at 03:52:02 UTC, Ryan wrote:
> Why do I see double `not` operators sometimes in D code? An 
> example it the last post of this thread.
>
> http://forum.dlang.org/thread/ktlpnikvdwgbvfaamrsk@forum.dlang.org
>
>> import core.sys.windows.windows : GetConsoleCP;
>> bool hasConsole = !!GetConsoleCP();
>
> Thanks.

It's a more concise way of writing:
     GetConsoleCP() != 0

You can do this in C/C++ as well (and presumably some other 
languages).


More information about the Digitalmars-d-learn mailing list