[](p1)
public
Element Reference—Retrieves the
value object corresponding to the key object. If not found, returns the default value (see Hash::new for details).
h = { "a" => 100, "b" => 200 }
h["a"]
h["c"]
Show source
VALUE
rb_hash_aref(VALUE hash, VALUE key)
{
st_data_t val;
if (!RHASH(hash)->ntbl || !st_lookup(RHASH(hash)->ntbl, key, &val)) {
return hash_default_value(hash, key);
}
return (VALUE)val;
}