Remembering the Ternary Operator Syntax

后端 未结 7 1831
误落风尘
误落风尘 2021-01-05 08:11

Anyone have a good trick to remember the standard ternary syntax?

Specifically whether the \'?\' or \':\' comes first. I have consistently gotten this backwards over

7条回答
  •  情书的邮戳
    2021-01-05 08:36

    If you're unit tests still pass when you get it wrong, then either it doesn't matter or your tests aren't covering enough of the paths through the code. If there's too long a gap between typing it and getting a pass/fail from the tests, that's another issue. Very few little syntax nits matter in the presence of good, fast tests.

提交回复
热议问题