DMD 0.149 release (on bools)

BCS BCS_member at pathlink.com
Tue Mar 7 18:12:41 PST 2006


> It's not like anybody would want to write exactly
> 
>     bool x = 5;
> 
> but more like
> 
>     bool x = strcmp("foo", "bar");
>     if (!x) { /* do stuff */ }        // match
>     else { /* call the cops! */ }     // no match
> 

"!!" ends up as a cast to bool

try:

import std.stdio;

int main()
{
	int i = 1;
	int j = 2;
	int k = 0;

	if(!!i)writef("i\n");else writef("!i\n");
	if(!!j)writef("j\n");else writef("!j\n");
	if(!!k)writef("k\n");else writef("!k\n");

	return 0;
}



More information about the Digitalmars-d-announce mailing list