Skip to content

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

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.

See also .reject! .rehash .rassoc .replace also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0