Just A Programmer » My strange ternary operator indenting

My strange ternary operator indenting

Posted by Justin on April 7th, 2010 filed in Just A Programmer

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.


One Response to “My strange ternary operator indenting”

  1. Ben Says:

    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.

Leave a Comment

You must be logged in to post a comment.