On Mar 28, 2012, at 6:10 PM, Chuck Hill wrote:

>>> One must learn the language syntax. Why should I use such a verbosity in 
>>> code when it's already easy to understand.
>>> 
>>> int max = (x > y) ? x : y;
>>> 
>>> is much better in readability than:
>>> 
>>> int max = 0;
>>> 
>>> if (x > y) {
>>>     max = x;
>>> } else {
>>>     max = y;
>>> }
>> 
>> See, that's the thing, I find the second form much easier to read and to be 
>> sure that I know exactly what is happening.
> 
> In this particular case, I'd prefer the former as it is small, short and 
> requires less reading to understand the intent of the code.  That said, the 
> ternary operator should be used with caution when the line gets longer.

Longer? Just nest them!
        
        a?
                b?
                        f():
                        c?
                                g():
                                h():
                d?
                        i():
                        j();

Next time, I'll show you how to combine them with bitwise operations, inside of 
switches with labeled breaks! ;-) I say this half jokingly.  I'm guilty of 
using nested elvis operators on occasion.  Looks perfectly intelligible to me.  
I try to refrain as I know everyone else wants to cut my fingers off whenever 
they see them. :-D

Ramsey
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to