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.to_hash

ENV.to_hash → hash of name/value pairs

Returns a Hash containing all name/value pairs from ENV:

Example
ENV.replace('foo' => '0', 'bar' => '1')
ENV.to_hash # => {"bar"=>"1", "foo"=>"0"}
See also .to_h .to_s .to_a .update also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0