Skip to content
On this page
class · Ruby 4.0

KeyError

< IndexError 2 instance methods 1 class methods

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"

Class methods 1

Instance methods 2