4 ms·
Now, let us suppose that expression a has side-effects... "But that's just stupid!" Yes. Now, given that a has side-effects...
by to3m 14y ago
Now, let us suppose that expression a has side-effects...
"But that's just stupid!"
Yes. Now, given that a has side-effects...
- Cushman 14y agoSuppose I want to `printf("Returning. A: %i", a)`. Same answer.
- georgeorwell 14y agoAssuming a has type int: int a_val = a; if (a_val) printf ("returning b"); return a_val ? b : c; Anyway, it's not useful for complicated code that needs to do lots of stuff. It's useful for simple code that ends up being more verbose with if-else. It's also useful for enforcing behaviour.