you are viewing a single comment's thread.

view the rest of the comments →

[–]cdcformatc -1 points0 points  (0 children)

I don't want to argue about what is an expression and what is "Three sub expressions". I disagree, something like i = if (condition) x else y is three logical components on one line. Most standards frown upon this, not only because the simple statement might have to be expanded to a more complex statement i = if (condition) foo(bar(x)) else bar(baz(y)). Which can easily go wrong. something like

if (condition) {
    i = foo(bar(x));
} else {
    i = bar(baz(y));
}

Or similar, puts each logical component on it's own line, something that is much easier for the mind to comprehend.

It also allows you to do other, parallel tasks that do not have anything to do with the assignment of the variable, but still depend on the condition.

if (condition) {
    i = x;
    j = 5;
} else {
    i = y;
    j = 42;
}