From: Ned Konz Date: 2002-07-22T03:43:26+09:00 Subject: Re: module_eval: adding a method to a class with a proc On Sunday 21 July 2002 11:17 am, Tom Sawyer wrote: > x = Proc.new { 5 + 5 } > > class C > def initialize > end > end > > C.module_eval { > def ten > x > end > } > You've got a scoping problem, and x isn't visible inside "def ten". This works (I think), but I'm not sure what you're trying to do, exactly, so I don't know if it solves the problem. $x = Proc.new { 5 + 5 } class C def initialize end end C.module_eval { def ten $x.call end } c = C.new puts c.ten() -- Ned Konz http://bike-nomad.com GPG key ID: BEEA7EFE