The fetch()
method of the ENV
class fetches or finds an environment variable. It takes the environment variable’s name and returns the value of this environment variable.
ENV.fetch(name)
name
: This is the name of the environment variable we want to find.The value returned is the value of the environment variable that was fetched.
# create some environment variablesENV["A"] = "Apple"ENV["M"] = "Meta"ENV["G"] = "Google"# fetch some environment variablesputs ENV.fetch("A")puts ENV.fetch("G")puts ENV.fetch("M")