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_a

ENV.to_a → array of 2-element arrays

Returns the contents of ENV as an Array of 2-element Arrays, each of which is a name/value pair:

Example
ENV.replace('foo' => '0', 'bar' => '1')
ENV.to_a # => [["bar", "1"], ["foo", "0"]]
See also .store .to_h .slice .to_hash also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0