Bools reloaded
Bruno Medeiros
daiphoenixNO at SPAMlycos.com
Sat Mar 4 02:27:18 PST 2006
Ivan Senji wrote:
> xs0 wrote:
>> Even though I don't mind typing something as simple as
>>
>> if (a!=null)
>>
>> the verbosity of longer expressions really annoys the heck out of me.
>> Now, I prefer
>>
>> > if (a && b && c && d) // check for nulls
>
> But what is going on behind the scene if a,b,c,d are ints or ponters,
> conversions to bools? I still don't get it how logic && operator can be
> aplied to integers. What is 5 && 3? (Except two numbers: 5,3.) It has no
> value regarding truth. It is neither true nor false.
>
>
With the behavior implicit conversion from int to bool, "5 && 3" becomes
"true && true".
--
Bruno Medeiros - CS/E student
"Certain aspects of D are a pathway to many abilities some consider to
be... unnatural."
More information about the Digitalmars-d
mailing list