summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-catch/mrblib
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2021-02-06 16:57:36 +0900
committerGitHub <[email protected]>2021-02-06 16:57:36 +0900
commit0bd01c545f13521fc57932f5e2decd4570152331 (patch)
tree7af5932607dba8bb35a6ef62c01b28afb9e435c3 /mrbgems/mruby-catch/mrblib
parent4bf4650321c540a8abf31aa801afc0e8545571f6 (diff)
parent1ea4c512450a79e979b2652764b35a28630f5570 (diff)
downloadmruby-0bd01c545f13521fc57932f5e2decd4570152331.tar.gz
mruby-0bd01c545f13521fc57932f5e2decd4570152331.zip
Merge pull request #5323 from shuujii/make-the-argument-of-Kernel-catch-optional-as-Ruby-does
Make the argument of `Kernel#catch` optional as Ruby does
Diffstat (limited to 'mrbgems/mruby-catch/mrblib')
-rw-r--r--mrbgems/mruby-catch/mrblib/catch.rb15
1 files changed, 5 insertions, 10 deletions
diff --git a/mrbgems/mruby-catch/mrblib/catch.rb b/mrbgems/mruby-catch/mrblib/catch.rb
index f8dcb3e84..68b165c8d 100644
--- a/mrbgems/mruby-catch/mrblib/catch.rb
+++ b/mrbgems/mruby-catch/mrblib/catch.rb
@@ -1,22 +1,17 @@
class ThrowCatchJump < Exception
+ attr_reader :_tag, :_val
def initialize(tag, val)
- @tag = tag
- @val = val
+ @_tag = tag
+ @_val = val
super("uncaught throw #{tag.inspect}")
end
- def _tag
- @tag
- end
- def _val
- @val
- end
end
module Kernel
- def catch(tag, &block)
+ def catch(tag=Object.new, &block)
block.call(tag)
rescue ThrowCatchJump => e
- unless e._tag == tag
+ unless e._tag.equal?(tag)
raise e
end
return e._val