Merge pull request #2956 from Asmod4n/master

Problem: Hash#fetch doesn't raise KeyError when a key cannot be found
This commit is contained in:
Yukihiro "Matz" Matsumoto
2015-09-18 23:19:51 +09:00
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -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
+1 -1
View File
@@ -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