logoalt Hacker News

addaonyesterday at 5:32 PM4 repliesview on HN

But if you spell that `assert(false)` instead of as a comment, the intent is equally clear, but the behavior when you're wrong is well-defined.


Replies

JohnFenyesterday at 5:36 PM

I agree that including that assert along with the comment is much better. But the comment alone is better than nothing, so isn't without value.

etermyesterday at 5:36 PM

Better yet, `assert(false, message)`, with the message what you would have written in the comment.

show 1 reply
zffryesterday at 6:49 PM

At least on iOS, asserts become no-ops on release builds

show 2 replies
fwipyesterday at 9:00 PM

I think you might have missed that they threw an exception right under the comment.