From: Robert Dober Date: 2008-11-01T02:59:43+09:00 Subject: Re: How to access to local variables in enclosing scopes? Ruby, in it's infinite wisdom; gives you a cake that you can have and eat. x = 42 def a; x end # does not work!! Why? Because it is efficient, there is no closure and that means one context less to look up at runtime. If however you want the closure (as I often do) you can still do it x = 42 class << self; self end.module_eval do define_method :a do x end define_method :a= do |new_x| x = new_x end end puts a a = 43 puts a #! The next one is important ! puts x Note the class << self; self end.module_eval but I guess you know why I am doing this... ... class << self end does not create a closure. HTH Robert -- C'est véritablement utile puisque c'est joli. Antoine de Saint Exupéry