To be clear - this code is running perfectly - code with proc
but if instead I change Proc.new to lambda, I'm getting an error
ArgumentError: wrong number of arguments (1 for 0)
May be this is because instance_eval wants to pass self as a param, and lambda treats as a method and do not accept unknown params?
There is two examples - first is working:
class Rule
def get_rule
Proc.new { puts name }
end
end
class Person
attr_accessor :name
def init_rule
@name = "ruby"
instance_eval(&Rule.new.get_rule)
end
end
second is not:
class Rule
def get_rule
lambda { puts name }
end
end
class Person
attr_accessor :name
def init_rule
@name = "ruby"
instance_eval(&Rule.new.get_rule)
end
end
Thanks