Commit 4bd98671 authored by Asmod4n's avatar Asmod4n

Problem: Hash#fetch doesn't raise KeyError when a key cannot be found

Solution: change the Exception class raised to KeyError when a key
cannot be found.
parent e6d9b450
......@@ -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