Despite using ENV all the time, this article made me actually question what the hell it actually is, i.e. how it is implemented. It quacks very muck like a Hash, so after reading this I thought all these solutions a bit ceremonious. Why not just set ENV's default proc to raise a KeyError to behave like Hash#fetch:
Anyway, a real simple way to have ENV[] behave like ENV.fetch is to define a method on ENV's metaclass:
This worked fine in irb but use fetch, intent is clearer.