Flowdock
initialize_copy(p1) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
static VALUE
rb_hash_initialize_copy(VALUE hash, VALUE hash2)
{
    st_table *ntbl;

    rb_hash_modify_check(hash);
    hash2 = to_hash(hash2);

    Check_Type(hash2, T_HASH);

    if (hash == hash2) return hash;

    ntbl = RHASH(hash)->ntbl;
    if (RHASH(hash2)->ntbl) {
        if (ntbl) st_free_table(ntbl);
        RHASH(hash)->ntbl = st_copy(RHASH(hash2)->ntbl);
        if (RHASH(hash)->ntbl->num_entries)
            rb_hash_rehash(hash);
    }
    else if (ntbl) {
        st_clear(ntbl);
    }

    if (FL_TEST(hash2, HASH_PROC_DEFAULT)) {
        FL_SET(hash, HASH_PROC_DEFAULT);
    }
    else {
        FL_UNSET(hash, HASH_PROC_DEFAULT);
    }
    RHASH_SET_IFNONE(hash, RHASH_IFNONE(hash2));

    return hash;
}
Register or log in to add new notes.