Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
ENV.reject
ENV.reject { |name, value| block } → hash of name/value pairs
ENV.reject → an_enumerator
hash.c
View on GitHub ↗
static VALUE
env_reject(VALUE _)
{
return rb_hash_delete_if(env_to_hash());
}
Yields each environment variable name and its value as a 2-element Array. Returns a Hash whose items are determined by the block. When the block returns a truthy value, the name/value pair is added to the return Hash; otherwise the pair is ignored:
Example
ENV.replace('foo' => '0', 'bar' => '1', 'baz' => '2') ENV.reject { |name, value| name.start_with?('b') } # => {"foo"=>"0"}
Returns an Enumerator if no block given:
Example
e = ENV.reject e.each { |name, value| name.start_with?('b') } # => {"foo"=>"0"}