Just A Programmer We’re Just Programmers…

7Apr/101

My strange ternary operator indenting

I’ve always indented ternary operator (?:) statements like so in languages that support them:

int fooCount = (isSeven)
    ? 7
    : int.MaxValue;

I’ve never seen anyone else do it this way , but no one has complained about my style to my knowledge. If anyone has a strong opinion on the matter, for or against it, I’d like to know.

Posted by Justin

  • Ben

    You use a ternary to save space.

    You are completely missing the point.

    You’ve turned this little nothing piece of easy to read code:

    int fooCount = int.MaxValue;
    if(isSeven) fooCount = 7;

    Into that hard to read monstrosity you posted.

  • Pingback: Justin Dearing