On this page
Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
class · Ruby 3.3
KeyError
Raised when the specified key is not found. It is a subclass of IndexError.
Example
h = {"foo" => :bar} h.fetch("foo") #=> :bar h.fetch("baz") #=> KeyError: key not found: "baz"