Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
ENV.each_value
ENV.each_value { |value| block } → ENV
ENV.each_value → an_enumerator
hash.c
View on GitHub ↗
static VALUE
env_each_value(VALUE ehash)
{
VALUE values;
rb_len_t i;
RETURN_SIZED_ENUMERATOR(ehash, 0, 0, rb_env_size);
values = env_values();
for (i=0; i<RARRAY_LEN(values); i++) {
rb_yield(RARRAY_AREF(values, i));
}
return ehash;
}
Yields each environment variable value:
Example
ENV.replace('foo' => '0', 'bar' => '1') # => ENV values = [] ENV.each_value { |value| values.push(value) } # => ENV values # => ["1", "0"]
Returns an Enumerator if no block given:
Example
e = ENV.each_value # => #<Enumerator: {"bar"=>"1", "foo"=>"0"}:each_value> values = [] e.each { |value| values.push(value) } # => ENV values # => ["1", "0"]