Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
ENV.reject
ENV.reject {|name, value| ... } → hash
ENV.reject → new_enumerator
hash.c
View on GitHub ↗
static VALUE
env_reject(VALUE _)
{
return rb_hash_delete_if(env_to_hash());
}
Calls the block with each environment variable name and value. Returns a Hash whose items are determined by the block. When the block returns a truthy value, the name/value pair is ignored; otherwise the pair is added to the return Hash:
Example
ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2') ENV.reject { |name, value| name.start_with?('b') } # => {"foo"=>"0"}
Returns a new Enumerator if no block is given.