DMD 0.149 release (on bools)
Derek Parnell
derek at psych.ward
Tue Mar 7 18:17:14 PST 2006
On Tue, 07 Mar 2006 18:12:41 -0800, BCS wrote:
>> 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;
> }
LOL.... try this too.
writefln("%s %s", !!i, !!k);
I get "true false" in return.
Now this qualifies as a real D-Geek operator.
--
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
8/03/2006 1:15:38 PM
More information about the Digitalmars-d-announce
mailing list