compact!()
public
Removes all nil values from the hash. Returns nil if no changes were made,
otherwise returns the hash.
h = { a: 1, b: false, c: nil }
h.compact!
static VALUE
rb_hash_compact_bang(VALUE hash)
{
st_index_t n;
rb_hash_modify_check(hash);
n = RHASH_SIZE(hash);
if (n) {
rb_hash_foreach(hash, delete_if_nil, hash);
if (n != RHASH_SIZE(hash))
return hash;
}
return Qnil;
}