When defining a singleton method, I want to refer to variables in the scope
outside the def. Is it possible to do something like the following?
class C
def initialize
@child = Object.new
s = self
def @child.parent
s # Wrong. But how do I refer to the instance of C?
end
end
attr_reader :child
end
c = C.new
c == c.child.parent # Should be true.
Any hints? I think I'm missing a vital piece of magic here. Or maybe I'm
expecting too much Lisp-ness.
k