Skip to content

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

class method

ENV.rassoc

ENV.rassoc(value) → [name, value] or nil

Returns a 2-element Array containing the name and value of the first found environment variable that has value value, if one exists:

Example
ENV.replace('foo' => '0', 'bar' => '0')
ENV.rassoc('0') # => ["bar", "0"]

The order in which environment variables are examined is OS-dependent. See About Ordering.

Returns nil if there is no such environment variable.

See also .merge! .rehash .member? .reject also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0