[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Does an instance know his own name?

e

9/4/2006 2:24:00 AM

Geoff Barnes wrote:
> If a class has built checks and raises an exception if it finds
> something wrong, how can I tell which instance had the error? I know
> there's an object_id, but can I know the name of the objects own
> instance variable?
>
> <snip />
>
> Also, can an instance know his 'path' from the top-level?
>
> <snip />

No and no (at least, no sensible way). You are dealing with
symbolic names 'huey' versus actual references and objects.

The 'proper' way is to have the object know its name:

huey = Nephew.new 'Huey'

> Thanks,


--
Posted via http://www.ruby-....