On Thu, Mar 15, 2007 at 10:57:54PM +0900, Damjan Rems wrote:
> What I am trying to accomplist is:
> 
>   class MyClass
>     def addVar(var, val)
>       instance_variable_set("@#{var}", val)
>       define_method("#{var}")  { || instance_variable_get("#{var}") }

        self.class.class_eval {
          define_method("#{var}")  { || instance_variable_get("@#{var}") }
        }

>     end
>   end
> 
>   c = MyClass.new
>   c.addVar('aa',10)  # here pops the error
>   c.aa   # should return 10

Regards,

Brian.