Previous Up Next

12.2.4  Checking conditions: assert

The assert command breaks out of a function with an error.


Example.
Define the function:
Input:

sqofpos(x):= {assert(x > 0); return x^2;}

then:

sqofpos(4)

Output:

16

Input:

sqofpos(-4)

Output:

assert failure: x>0 Error: Bad Argument Value

since -4 > 0 is false.


Previous Up Next