The ENV.include?()
method in Ruby lets us check if a certain environment name is present in our environment variables. It returns a Boolean value.
ENV.include?(name)
name
: This is the name of the environment variable whose existence we want to check.
This method returns a Boolean value. If the environment variable exists, it returns a true
value. Otherwise, it returns a false
value.
# Creating some environment variablesENV["name"] = "Ruby"ENV["platform"] = "Edpresso"ENV["user_secret"] = "23423lsdfksld23"# Checking if some keys existputs ENV.include?("name")puts ENV.include?("platform")puts ENV.include?("admin_secret")