Re: [Hampshire] Code style

Kezdőlap

Reply to this message
Szerző: Stephen Rowles
Dátum:  
Címzett: Hampshire LUG Discussion List
Tárgy: Re: [Hampshire] Code style
Hugo Mills wrote:
>    Yet one more reason to avoid ternary operators... (If you haven't
> guessed yet, I'm not a fan of the whole concept. I've rarely met a use
> of the ternary operator, in any language, that made code easier to
> read.)

>
>    Hugo.

>

I use the following fairly regularly when writing debug output:

object == null ? "null" : object.getText();


Or similar. But only for debug output, I don't use ternary for main line
flow control, too much chance of someone else misunderstanding in the
future.