-
Notifications
You must be signed in to change notification settings - Fork 1
Try Operator
Ígor Bonadio edited this page Jun 18, 2015
·
2 revisions
-
The try operator safeguards against abnormal execution, which means saving programs that send messages to uninitialized variables.
-
The compiler must have enough safeguards so that sending a method to an object that doesn't respond to it may never happen, thus making the try operator not applicable.
-
Grammar
try_op : expr '~>' expr?
;- Examples:
let next_value_of_x = x.next() ~> 0 # returns the next value of x or 0 if it fails
obj.do_something() ~> # do_something() or, if it fails, do nothing.