4 ms·
How would you use the ternary operator there? Like this? image ? foo_release(image) : 0;
by TorKlingberg 11y ago
How would you use the ternary operator there? Like this?
image ? foo_release(image) : 0;
- dcvuob 11y agoYes. And cast that 0 to (void), so the compiler won't complain over an unused expression. Any C programmer will recognize what (void)0 means, do nothing.
- TorKlingberg 11y agoSure, but I find it strange to use the ternary operator and discarding the value. It's not wrong, but I think most C programmers prefer a simple if statement.
- dcvuob 11y agoI was giving an replacement for the if statement presented above, where both expressions are on the same line.