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

Basile B. via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 26 08:29:52 PDT 2016


On Thursday, 26 May 2016 at 15:25:03 UTC, arturg wrote:
> On Thursday, 26 May 2016 at 15:15:57 UTC, Basile B. wrote:
>> On Thursday, 26 May 2016 at 15:14:21 UTC, Basile B. wrote:
>>> On Thursday, 26 May 2016 at 15:11:50 UTC, Basile B. wrote:
>>>> On Thursday, 26 May 2016 at 14:03:16 UTC, ArturG wrote:
>>>>> [...]
>>>
>>>> [...]
>>>> - integral(*): if (i) <=> if (i > 0)
>>>
>>> I obviously meant:
>>>
>>> - integral(*): if (i) <=> if (i <> 0)
>>>
>>> and "<=>" stands for "equivalence"
>>
>> I obviously meant:
>>
>> integral(*): if (i) <=> if (i != 0),
>>
>> "<>" is the Pascal operator for C's "!=" ....
>
> yes i know about most of those shortcuts its just float.init 
> and char.init that work different then the other when you do 
> this
>
> if(someType) // will be true for float and char while someType 
> is T.init

float.init is not equal to 0.0f. In D FP points values are 
initialized to nan (not a number).

By the way for strings it works, it's like the array case I 
described in the first answer).


More information about the Digitalmars-d-learn mailing list