Maintenance Ruby 3.4 gets fixes, but no new features. 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 _)
{
bool empty = true;
ENV_LOCK();
{
char **env = GET_ENVIRON(environ);
if (env[0] != 0) {
empty = false;
}
FREE_ENVIRON(environ);
}
ENV_UNLOCK();
return RBOOL(empty);
}
Returns true when there are no environment variables, false otherwise:
Example
ENV.clear ENV.empty? # => true ENV['foo'] = '0' ENV.empty? # => false