Assertions: Difference between revisions

no edit summary
(→‎{{header|Kotlin}}: Add nuance between assertion, Errors, and checks.)
No edit summary
Line 1,374:
# the error message can be any expression</lang>
It is possible to turn off assertions by running Python with the <tt>-O</tt> (optimizations) flag.
 
=={{header|QB64}}==
<lang vb>$ASSERTS:CONSOLE
DO
a = INT(RND * 10)
b$ = myFunc$(a)
PRINT a, , b$
_LIMIT 3
LOOP UNTIL _KEYHIT
FUNCTION myFunc$ (value AS SINGLE)
_ASSERT value > 0, "Value cannot be zero"
_ASSERT value <= 10, "Value cannot exceed 10"
IF value > 1 THEN plural$ = "s"
myFunc$ = STRING$(value, "*") + STR$(value) + " star" + plural$ + " :-)"
END FUNCTION</lang>
 
=={{header|R}}==