End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
ENV.except
ENV.except(*keys) → a_hash
hash.c
View on GitHub ↗
static VALUE
env_except(int argc, VALUE *argv, VALUE _)
{
int i;
VALUE key, hash = env_to_hash();
for (i = 0; i < argc; i++) {
key = argv[i];
rb_hash_delete(hash, key);
}
return hash;
}
Returns a hash except the given keys from ENV and their values.
Example
ENV #=> {"LANG"=>"en_US.UTF-8", "TERM"=>"xterm-256color", "HOME"=>"/Users/rhc"} ENV.except("TERM","HOME") #=> {"LANG"=>"en_US.UTF-8"}
Ruby version changes
-
3.0
-
ENV.excepthas been added, which returns a hash excluding the given keys and their values. [Feature #15822]
-