From: 7stud -- Date: 2011-08-26T13:19:49+09:00 Subject: Re: calling a descendant's method Alexey Muranov wrote in post #1018534: > I think i've found an explanation: in fact i used a lambda and called a > class method in the body of the lambda, so probably `self` was bound to > the current self (the abstract class). > Sorry again for the bad question. class Dog def self.get_val 10 end def self.do_stuff #self = Dog x = 5 my_lambda = lambda { get_val() + x} #self.get_val() x += 1000 return my_lambda end end class Cat def self.get_val 0 end def self.execute_lambda(callable) #self = Cat x = 0 puts callable.call #{get_val() + x}.call() end end a_lambda = Dog.do_stuff Cat.execute_lambda(a_lambda) --output:-- 115 -- Posted via http://www.ruby-forum.com/.