Ruby Newbie homepage Ruby Newbie homepage

How to use

Quick guide

Official content
Returns a new Hash excluding entries for the given keys:
h = { a: 100, b: 200, c: 300 }
h.except(:a)          #=> {:b=>200, :c=>300}
Any given keys that are not found are ignored.
 
               static VALUE
rb_hash_except(int argc, VALUE *argv, VALUE hash)
{
    int i;
    VALUE key, result;

    result = hash_dup_with_compare_by_id(hash);

    for (i = 0; i < argc; i++) {
        key = argv[i];
        rb_hash_delete(result, key);
    }

    return result;
}
            

Was this page useful?