4 ms·
One ugly trick for unreachable branches is this: assert(!"You gave an invalid letter"); The string literal is a pointer, so !pointer is false. And then yo
by identity0 6y ago
One ugly trick for unreachable branches is this:
assert(!"You gave an invalid letter");
The string literal is a pointer, so !pointer is false. And then you get a nice explanation message when the assertion fails. I wish all assert gave optional explanation messages.
- saagarjha 6y agoI often do assert(condition && "String explanation") myself.