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)
{
    rb_hash_modify_check(hash);
    hash2 = to_hash(hash2);

    Check_Type(hash2, T_HASH);

    if (hash == hash2) return hash;

    if (RHASH_AR_TABLE_P(hash2)) {
        if (RHASH_AR_TABLE_P(hash)) ar_free_and_clear_table(hash);
        ar_copy(hash, hash2);
        if (RHASH_AR_TABLE_SIZE(hash))
            rb_hash_rehash(hash);
    }
    else if (RHASH_ST_TABLE_P(hash2)) {
        if (RHASH_ST_TABLE_P(hash)) st_free_table(RHASH_ST_TABLE(hash));
        RHASH_ST_TABLE_SET(hash, st_copy(RHASH_ST_TABLE(hash2)));
        if (RHASH_ST_TABLE(hash)->num_entries)
            rb_hash_rehash(hash);
    }
    else if (RHASH_AR_TABLE_P(hash)) {
        ar_clear(hash);
    }
    else if (RHASH_ST_TABLE_P(hash)) {
        st_clear(RHASH_ST_TABLE(hash));
    }

    COPY_DEFAULT(hash, hash2);

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