APIdock / Ruby
/
method

values

ruby latest stable - Class: Hash
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  #=> [100, 200, 300]
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;
 rb_gc_writebarrier_remember(values);
 RARRAY_PTR_USE(values, ptr, {
 size = st_values(table, ptr, size);
 });
 rb_ary_set_len(values, size);
 }
 else {
 rb_hash_foreach(hash, values_i, values);
 }
 return values;
}

AltStyle によって変換されたページ (->オリジナル) /