APIdock / Ruby
/
method

replace

ruby latest stable - Class: Hash
replace(p1)
public

Replaces the contents of hsh with the contents of other_hash.

h = { "a" => 100, "b" => 200 }
h.replace ({ "c" => 300, "d" => 400 }) #=> {"c"=>300, "d"=>400}
static VALUE
rb_hash_replace(VALUE hash, VALUE hash2)
{
 st_table *table2;
 rb_hash_modify_check(hash);
 if (hash == hash2) return hash;
 hash2 = to_hash(hash2);
 COPY_DEFAULT(hash, hash2);
 table2 = RHASH(hash2)->ntbl;
 rb_hash_clear(hash);
 if (table2) hash_tbl(hash)->type = table2->type;
 rb_hash_foreach(hash2, replace_i, hash);
 return hash;
}

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