Why do some T.init evaluate to true while others to false?

ArturG via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri May 27 08:19:50 PDT 2016


On Friday, 27 May 2016 at 15:07:50 UTC, Adam D. Ruppe wrote:
> On Friday, 27 May 2016 at 14:56:28 UTC, ArturG wrote:
>>    float f;
>>    if(f is float.init) "float init".writeln;
>>    f = float.nan;
>>    if(f is float.init) "float nan".writeln;
>
> You changed it to a value that isn't float.init, so of course 
> it isn't going to match!
>
> float.nan and float.init are NOT the same thing. float.init is 
> a kind of NAN, but not the same kind.

yes but i have to check for that when some one does

float.nan.checkThen!((f){ this fun should not run });

which should be the same as

float.init.checkThen!((f){ this fun should not run });


More information about the Digitalmars-d-learn mailing list