Re: [Hampshire] Code style

Top Page

Reply to this message
Author: Stephen Rowles
Date:  
To: Hampshire LUG Discussion List
Subject: 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.