Previous Up Next

25.2.4  Checking required conditions

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

Example

Define the function:

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

then:

sqofpos(4)
     
16           
sqofpos(-4)
     
“assert failure: x>0 Error: Bad Argument Value”           

since −4>0 is false.


Previous Up Next