Closed hollance closed 10 years ago
Are you happy with no parens for the following?
result = a ? x : y;
if a is a BOOL, no prob
On Fri, Nov 8, 2013 at 9:43 AM, ColinEberhardt notifications@github.comwrote:
Are you happy with no parens for the following?
result = a ? x : y;
— Reply to this email directly or view it on GitHubhttps://github.com/raywenderlich/objective-c-style-guide/issues/17#issuecomment-28047149 .
Cesare Rocchi http://studiomagnolia.com
I'm happy with a ? x : y
if a
is a BOOL, but I don't like it when I see this:
int a = ...
result = a ? x : y;
In other words, non-booleans should always compare against something:
result = (a != 0) ? x : y;
I suggest we write it as such:
In other words, place parentheses around the condition. There are two reasons for this: