values()
public
Returns a new array populated with the
values from hsh. See also
Hash#keys.
h = { "a" => 100, "b" => 200, "c" => 300 }
h.values
Show source
VALUE
rb_hash_values(VALUE hash)
{
VALUE values;
st_index_t size = RHASH_SIZE(hash);
values = rb_ary_new_capa(size);
if (size == 0) return values;
if (ST_DATA_COMPATIBLE_P(VALUE)) {
st_table *table = RHASH(hash)->ntbl;
if (OBJ_PROMOTED(values)) rb_gc_writebarrier_remember_promoted(values);
RARRAY_PTR_USE(values, ptr, {
size = st_values_check(table, ptr, size, Qundef);
});
rb_ary_set_len(values, size);
}
else {
rb_hash_foreach(hash, values_i, values);
}
return values;
}