Back to Sway

assert_eq

docs/reference/src/documentation/operations/assertions/assert-eq.md

0.71.0460 B
Original Source

assert_eq

The assert_eq function is automatically imported into every program from the prelude. It takes two expressions which are compared and the result is a Boolean. If the value is false then the virtual machine will revert.

Example

Here is a function which asserts that a and b must be equal.

sway
{{#include ../../../code/operations/assertions/src/lib.sw:assert_eq}}