class TryExpr var val as int def main x = 0 x = try int.parse('123') catch get 0 assert x == 123 # type inference y = try int.parse('x123') catch get 0 assert y == 0 # get expr not literal x = 666 y = try int.parse('123') catch get x assert y == 123 y = try int.parse('123x') catch get x-6 assert y == 660 x = try int.parse(nil to passthrough) catch get 0 assert x == 0 x = try int.parse(nil to passthrough) catch ArgumentNullException get 0 assert x == 0 expect ArgumentNullException x = try int.parse(nil to passthrough) catch FormatException get 0 .val = try int.parse('9909') catch get 0 assert .val == 9909 te2 = TryExpr() assert te2.val == 0 te2.val = try int.parse('100') catch get 0 assert te2.val == 100 dflt = '---' s0 = try String.format('{0:P}', 0.123) catch get dflt assert s0 == '12.30 %' s1 = try String.format('{1:P}', 0.123) catch FormatException get dflt assert s1 == dflt s1 = try String.format('{1:XP}', 0.123) catch FormatException get dflt assert s1 == dflt