From: Ryan Davis Date: 2010-06-18T08:34:19+09:00 Subject: [ruby-core:30802] Re: PATCH: ENV['key'] = non_string On Jun 17, 2010, at 15:57 , Yukihiro Matsumoto wrote: > Hi, > > In message "Re: [ruby-core:30799] PATCH: ENV['key'] = non_string" > on Fri, 18 Jun 2010 07:52:55 +0900, Ryan Davis writes: > > |Can I commit this please? This drives me bonkers. > > Can you elaborate? Basically "fail early" is a good principle. > I see no good reason to make > > ENV["foo"] = Object.new Sure: ENV["foo"] = 1 or: ENV["foo"] = true I actually use those a fair amount. I also played with this today: def ENV.method_missing msg, *args msg = msg.to_s if msg =~ /=$/ then self[msg[0..-2]] = args.first.to_s else self[msg] end end Changes: ENV["GEM_HOME"] = ENV["GEM_PATH"] = dir into: ENV.GEM_HOME = ENV.GEM_PATH = dir The #to_s inside the setter changes: ENV["BOOL"] = "1" into: ENV.BOOL = 1