Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Hash#default=

hash.default = value → object

Sets the default value to value; returns value:

Example
h = {}
h.default # => nil
h.default = false # => false
h.default # => false

See Default Values.