Mojo function
constrained
constrained[cond: Bool, msg: StringLiteral = "param assertion failed"]()
Compile time checks that the condition is true.
The constrained
is similar to static_assert
in C++ and is used to
introduce constraints on the enclosing function. In Mojo, the assert places
a constraint on the function. The message is displayed when the assertion
fails.
Parameters:
- βcond (
Bool
): The bool value to assert. - βmsg (
StringLiteral
): The message to display on failure.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!
If you'd like to share more information, please report an issue on GitHub
π What went wrong?