[top][index]
search for:

try -- catch an error

try x else y -- returns the value of x unless an error or alarm occurs during the evaluation of x, in which case it returns the value of y.
try x -- returns the value of x unless an error or alarm occurs during the evaluation of x, in which case it returns null.

The behavior of interrupts (other than alarms) is unaffected.

i1 : apply(-3..3,i->try 1/i else infinity)

        1    1                   1  1
o1 = (- -, - -, -1, infinity, 1, -, -)
        3    2                   2  3

o1 : Sequence

We will change the behavior of this function soon so that it will be possible to catch errors of a particular type. Meanwhile, users are recommended to use this function sparingly, if at all.


[top][index]
search for: