From: Gary Wright Date: 2011-03-08T14:44:44+09:00 Subject: Re: basic programming question, help please On Mar 8, 2011, at 12:14 AM, Mayank Kohaley wrote: >> > After putting @@x = "defined in B" in class B it shows "defined in B" and > not "defined in Object", and it makes sense as it works according to lexical > scope and not the dynamic scope. This is how I changed the class B without > changing anything else > > class B > @@a = "defined in B" > @@x = "defined in B" > A.send(:define_method, :show_a) { puts @@a } > A.send(:define_method, :show_x) { puts @@x } > end See my reply to Eric Christopherson's post for an explanation. Gary Wright