default_proc()
public
If Hash::new was invoked with a block, return that block, otherwise return
nil.
h = Hash.new {|h,k| h[k] = k*k }
p = h.default_proc
a = []
p.call(a, 2)
a
Show source
/*
* call-seq:
* hsh.default_proc -> anObject
*
* If <code>Hash::new</code> was invoked with a block, return that
* block, otherwise return <code>nil</code>.
*
* h = Hash.new {|h,k| h[k] = k*k } #=> {}
* p = h.default_proc #=> #<Proc:0x401b3d08@-:1>
* a = [] #=> []
* p.call(a, 2)
* a #=> [nil, nil, 4]
*/
static VALUE
rb_hash_default_proc(hash)
VALUE hash;
{
if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
return RHASH(hash)->ifnone;
}
return Qnil;
}