blob: 89eedf66a0e7549cefd21983d9318ab82ab82904 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
class ThrowCatchJump < Exception
def initialize(tag, val)
@tag = tag
@val = val
super("uncaught throw :#{tag}")
end
def _tag
@tag
end
def _val
@val
end
end
module Kernel
def catch(tag, &block)
block.call(tag)
rescue ThrowCatchJump => e
unless e._tag == tag
raise e
end
return e._val
end
def throw(tag, val=nil)
raise ThrowCatchJump.new(tag, val)
end
end
|