From: Kent Dahl Date: 2002-07-19T17:00:23+09:00 Subject: Re: #name of instance Tom Sawyer wrote: > i'm back at trying to get a form to be automagically update from changes > to an associated object. this is the first time i've really started to > hit dead ends with ruby... > > is there any way to get the name of an instance variable? What you appear to be asking for, is the name of the local variable (bobo) that holds the reference to the object on which the method is being called. I do not think this is possible, since it could be that there wasn't a local variable holding a reference when you called it (such as if you called A.new.myname). > class A > def myname > puts self.name # ? > end > end > > bobo = A.new > bob.myname Even with the name of a local variable in the outside scope, you'll need a binding to that scope to access it. A little more code showing what you want to do with the name of the local variable would probably spawn more concrete, useful answers than this one. -- (\[ Kent Dahl ]/)_ _~_ __[ http://www.stud.ntnu.no/~kentda/ ]___/~ ))\_student_/(( \__d L b__/ NTNU - graduate engineering - 4. year ) ( \__\_�|�_/__/ ) _)Industrial economics and technological management( \____/_�_\____/ (____engineering.discipline_=_Computer::Technology___)