Commit 9586aaa8 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2956 from Asmod4n/master

Problem: Hash#fetch doesn't raise KeyError when a key cannot be found
parents 070e04ea 4bd98671
...@@ -130,7 +130,7 @@ class Hash ...@@ -130,7 +130,7 @@ class Hash
elsif none != NONE elsif none != NONE
none none
else else
raise RuntimeError, "Key not found: #{key}" raise KeyError, "Key not found: #{key}"
end end
else else
self[key] self[key]
......
...@@ -79,7 +79,7 @@ assert('Hash#fetch') do ...@@ -79,7 +79,7 @@ assert('Hash#fetch') do
begin begin
h.fetch("gnu") h.fetch("gnu")
rescue => e rescue => e
assert_kind_of(StandardError, e); assert_kind_of(KeyError, e);
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment