3 ms·
What (besides the words if and else and the curly braces) makes the if/else equivalent more verbose)?
by hibbelig 6y ago
What (besides the words if and else and the curly braces) makes the if/else equivalent more verbose)?
- usefulcat 6y agoIn C and C++, ternaries are frequently used on the right hand side of an assignment statement. if/else can't be used in such a context. Here's a concrete example: const int min = x < y ? x : y; int min; if (x < y) min = x; else min = y; Note also that this prevents variable min from being made const, unless you are using c++ and wrap the entire if/else in an immediately invoked lambda, which of course would require additional verbosity.