|
|
|
|
|
by orangecat
1555 days ago
|
|
The if-else form, although longer, is unquestionably clearer. I disagree: - The variable name is repeated three times, increasing visual clutter and the chance of typos. - The variable can't declared immutable. In Java/JS/Dart/etc it's nice to know that after "const x = foo ? bar : baz", x won't change. And you don't even have to add a new operator, Rust and Kotlin get these benefits with an expression form of if/else. |
|