I want to use the value of a variable in my eval. How can I do that?
The following code snippet:
class Adder
def initialize(i)
@i = i
end
def method_missing(methodName)
self.class.class_eval do
def #{methodName}
return @i+20
end
end
end
end
Gives the error formal argument cannot be an instance variable on Line 9
define_methodmethod to define methods in runtime.