From: Robert Klemme Date: 2007-08-24T04:36:28+09:00 Subject: Re: Changing "self" for cleaner code On 23.08.2007 12:24, come wrote: > Yes ! > I didn't think about using instance_eval this way and define my own > "with" method... I'm still not confortable with metaprogramming ;-) You don't need to. You can simply use instance_eval directly: File.open("foo", "w") do |x| x.instance_eval do puts "hello" end end Although I have to say I find this a bit clumsy. I'd prefer File.open("foo", "w") do |io| io.puts "hello" end Even if there were more IO operations I had to do on "io". The piece above could be easily confused with printing to $defout. Just my 0.02EUR... Kind regards robert