| Previous | Reductive Labs, LLC | Next |
Blocks: Any CleanupE.g., environment cleanup: def withenv(hash) oldvals = {} hash.each do |name, val| name = name.to_s oldvals[name] = ENV[name] ENV[name] = val end yield ensure oldvals.each do |name, val| ENV[name] = val end end ENV["testing"] = "initial" withenv :testing => "interior" do puts "Inside the method: " + ENV["testing"] end puts "Outside the method: " + ENV["testing"]
Produces:
|
| Previous | Luke Kanies luke@reductivelabs.com | Index | Next |