May 2018
Beginner
252 pages
6h 19m
English
Use the type-test error? function in combination with try to test whether the code returns an error:
error? try [4 < "abc"] ;== true
The error? try phrase returns true in the case of an error and false otherwise.
We could use this to see if there is a runtime error with a condition test, phrased as if error?try:
if error? try [4 < "abc"][ print "Wrong input, enter an integer!" quit ; or: continue]
We could also use either error? try:
either error? try [4 < "abc"][ print "Wrong input, enter an integer!" quit ; or: continue