Hacker News new | ask | show | jobs
by _28jh 2035 days 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.
1 comments

I often do assert(condition && "String explanation") myself.