|
|
|
|
|
by jonahx
2745 days ago
|
|
> FTR, with "most certainly" you're committing the same fault your accusing the Go team here. Fair enough. It's too late to edit. > I don't understand the difference between this suggested phrasing and talking about clarity. I'd argue you tend to shoot yourself in the foot if and only if you aren't clear about what you're doing. This is partially true but it's not that simple imo. In my OP, the ternary version is clearer. But if you allow it, then you also open the door to nested ternaries, and foot shooting. Allowing single line if statements (as, eg, ruby does) also allows for clearer code, at the expense of consistency. |
|
This (or rather allowing conditionals without braces) was what I was referring to. They are a foot-gun, because of the lack of clarity. It's a common source of bugs in C/C++ code that a developer thought they'd add a line of code to a conditional block or loop but didn't, because of a lack of braces. Requiring braces unconditionally make it always unambiguous and obvious what block a given statement belongs to.
Obviously YMMV - this is, as most discussions in programming, a matter of opinion. Which was my point :)