length()
public
Returns the number of key-value pairs in the hash.
h = { "d" => 100, "a" => 200, "v" => 300, "e" => 400 }
h.length
h.delete("a")
h.length
Show source
/*
* call-seq:
* hsh.length => fixnum
* hsh.size => fixnum
*
* Returns the number of key-value pairs in the hash.
*
* h = { "d" => 100, "a" => 200, "v" => 300, "e" => 400 }
* h.length #=> 4
* h.delete("a") #=> 200
* h.length #=> 3
*/
static VALUE
rb_hash_size(hash)
VALUE hash;
{
return INT2FIX(RHASH(hash)->tbl->num_entries);
}