Best way to compare primitive types

Ary Manzana ary at esperanto.org.ar
Tue May 8 10:32:29 PDT 2007


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


More information about the Digitalmars-d-learn mailing list