From: Dave Baldwin Date: 2007-10-09T00:16:25+09:00 Subject: Accessing class variables in method made using define_method I want to use class variables and have them accessible from class methods that have been defined outside of the class using define_method or something similar. When I try this the class variable isn't in scope. A simple test case is: class A @@aa = 20 end A.class_eval {define_method(:foo){puts @aa}} a = A.new a.foo => nil and not 20 as expected or using A.send(:define_method, :foo){puts @aa} a.foo => nil and not 20 as expected gives the same result but class A def foo puts @@aa end end a.foo => 20 as expected. How do I get the same behaviour as opening the class and defining the method normally? Thanks, Dave.