pub fn require<T>(condition: bool, value: T)
Expand description
Checks if the given condition
is true
and if not, logs value
and reverts.
Arguments
condition
: [bool] - The condition upon which to decide whether to revert or not.value
: [T] - The value which will be logged in casecondition
isfalse
.
Reverts
- Reverts when
condition
isfalse
.
Examples
fn foo(a: u64, b: u64) {
require(a == b, "a was not equal to b");
// If the condition was true, code execution will continue
log("The require function did not revert");
}