default_proc=

hsh.default_proc = proc_obj or nil
Instance Public methods

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

1
2
3
4
5
h.default_proc = proc do |hash, key|
  hash[key] = key + key
end
h[2]       #=> 4
h["cat"]   #=> "catcat"
doc_ruby_on_rails
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.