Marcin Raczkowski wrote:
> On Thursday 15 March 2007 13:57, Damjan Rems wrote:
>>   c.addVar('aa',10)  # here pops the error
>> Advice me please
>>
>> TheR
> define_method won't work in instance method, you have to use class 
> method o
> just use eval("def #{var}; here return value; end");

Yep: Each of these two variants work:
     eval "def #{var};instance_variable_get('@#{var}');end"
     eval("def #{var}; @#{var}; end")

I was trying this too, but forgot to add @ to variable name.


Thanks

TheR


-- 
Posted via http://www.ruby-forum.com/.