朱莉娅:在断言中添加自定义消息?
Julia: add custom message in assert?
在 Python 中,我可以将自定义消息添加到断言以帮助代码开发:
assert False, "Expected true"
我如何在 Julia 中做同样的事情?
@assert false "Expected true"
@assert cond [text]
Throw an AssertionError
if cond
is false
. Preferred syntax for writing assertions. Message text
is optionally displayed upon assertion failure.
在 Python 中,我可以将自定义消息添加到断言以帮助代码开发:
assert False, "Expected true"
我如何在 Julia 中做同样的事情?
@assert false "Expected true"
@assert cond [text]
Throw an
AssertionError
ifcond
isfalse
. Preferred syntax for writing assertions. Messagetext
is optionally displayed upon assertion failure.