3
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
this post was submitted on 13 Jun 2023
3 points (100.0% liked)
Java
1369 readers
4 users here now
For discussing Java, the JVM, languages that run on the JVM, and other related technologies.
founded 1 year ago
MODERATORS
You are not wrong that they are in a way "executable comments". Just like comments they are intended only for development/debugging and can't (shouldn't) have any influence on production code.
For example, in your sample code the
if
is unnecessary, becausecondition
can't be (should not be)true
. If it were, it would be a bug. Instead it should be written as:If the condition can ever be
true
then you shouldn't be usingassert
.See also https://stackoverflow.com/a/2758645/318493