method

default_proc=

v2_4_6 - Show latest stable - Class: Hash
default_proc=(p1)
public

Sets the default proc to be executed on each failed key lookup.

h.default_proc = proc do |hash, key|
  hash[key] = key + key
end
h[2]       #=> 4
h["cat"]   #=> "catcat"