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
elsif none != NONE
none
else
raise RuntimeError, "Key not found: #{key}"
raise KeyError, "Key not found: #{key}"
end
else
self[key]
......@@ -156,7 +156,7 @@ class Hash
self.each do |k, v|
self.delete(k) if block.call(k, v)
end
end
self
end
......
......@@ -79,7 +79,7 @@ assert('Hash#fetch') do
begin
h.fetch("gnu")
rescue => e
assert_kind_of(StandardError, e);
assert_kind_of(KeyError, e);
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