Best way to compare primitive types

Ary Manzana ary at esperanto.org.ar
Tue May 8 10:35:18 PDT 2007


Ary Manzana escribió:
> Henning Hasemann escribió:
>> On Tue, 08 May 2007 09:43:28 -0300
>> Ary Manzana <ary at esperanto.org.ar> wrote:
>>
>>> Maybe something like this:
>>> ---
>>> int opCmp(T other) {
>>>      return this.value > other ? 1 :
>>>          (this.value < other ? -1 : 0);
>>> }
>>
>> I always write this as:
>>
>> return this.value < other ? -1 : this.value > other;
>>
>> Which is more leet (read unreadable) ,-)
>>
>> Henning
> 
> Oh... That's because I'm almost always programming in Java (int can be 
> converted to a boolean). :-P

Obviously I mistyped the word "can". It should be "can't".


More information about the Digitalmars-d-learn mailing list