Re: [Hampshire] Code style

Startseite

Nachricht beantworten
Autor: Stephen Rowles
Datum:  
To: Hampshire LUG Discussion List
Betreff: 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.