End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
class method
ENV.empty?
ENV.empty? → true or false
hash.c
View on GitHub ↗
static VALUE
env_empty_p(VALUE _)
{
char **env;
env = GET_ENVIRON(environ);
if (env[0] == 0) {
FREE_ENVIRON(environ);
return Qtrue;
}
FREE_ENVIRON(environ);
return Qfalse;
}
Returns true when there are no environment variables, false otherwise:
Example
ENV.clear ENV.empty? # => true ENV['foo'] = '0' ENV.empty? # => false