IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0.0b1
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

assert_true

assert_true[T: Boolable, //](val: T, msg: String = "condition was unexpectedly False", *, location: Optional[SourceLocation] = None)

Asserts that the input value is True and raises an Error if it's not.

Parameters:

  • T (Boolable): The type of the value argument.

Args:

  • val (T): The value to assert to be True.
  • msg (String): The message to be printed if the assertion fails.
  • location (Optional[SourceLocation]): The location of the error (defaults to call_location).

Raises:

An Error with the provided message if assert fails and None otherwise.