Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

ENV.clear

ENV.clear → ENV

Removes every environment variable; returns ENV:

Example
ENV.replace('foo' => '0', 'bar' => '1')
ENV.size # => 2
ENV.clear # => ENV
ENV.size # => 0
See also .assoc .delete .[]= .delete_if also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1