We can check if there are no environment variables using the empty?
property of the ENV
class. It returns true
if the environment variables are available, otherwise, it returns a false
.
ENV.empty?
The value returned is a Boolean. It returns true
if there are environment variables available, otherwise, it returns `false.
# create some environment variables ENV["G"] = "Google" ENV["N"] = "Netflix" ENV["A"] = "Apple" ENV["A"] = "Amazon" ENV["M"] = "Meta" ENV["FOO"] = "" # check if empty puts ENV.empty? # false # clear environment variables ENV.clear # check if empty puts ENV.empty? # true
RELATED TAGS
CONTRIBUTOR
View all Courses