2010/5/19 Walle Wallen <walle.sthlm / gmail.com>:
> Quick question. Can I somehow retrieve the instance of the class Test in
> which the variable con exists. As in the example below, can I retrieve
> the instance of Test from the variable p?

There is no general mechanism that would allow to follow an object
reference backwards.  If there was, that mechanism would yield
multiple instances because a object can be referenced by any number of
other objects.

Bottom line: you can only follow object references from the container
to the contained so you need to make sure you have the reference you
need (see below).

> class Test
>  ¨Βττςίαγγεσσος Ίγοξ
>
> def initialize()
>  ¨ΒγοΘασθ®ξεχ
> end
>
> end
>
> p = Test.new.con

t = Test.new
p = t.com

Btw, p might not be a good name for a local variable as it may lead to
confusion with method p.

Kind regards

robert


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/