logoalt Hacker News

puschkinfryesterday at 9:17 PM2 repliesview on HN

No, because the string will be implicitly converted to `true` and `(a && true) == a` (for boolean `a`), so it will only be `false` if the assertion fails. Using || would always evaluate to `true`


Replies

wpollockyesterday at 11:15 PM

You're right, thanks!

This works too (but I wouldn't recommend it):

   assert( someBooleanExpression || ! "It is false" );