instance method
Hash#default_proc
() -> (::Proc | nil)
default_proc → proc or nil
hash.c
View on GitHub ↗
static VALUE
rb_hash_default_proc(VALUE hash)
{
if (FL_TEST(hash, RHASH_PROC_DEFAULT)) {
return RHASH_IFNONE(hash);
}
return Qnil;
}
Returns the default proc for self (see Hash Default):
Example
h = {} h.default_proc # => nil h.default_proc = proc {|hash, key| "Default value for #{key}" } h.default_proc.class # => Proc