From: Tom Sawyer Date: 2002-07-19T16:53:08+09:00 Subject: Re: #name of instance good points, quite right. your notions did make me rethink and... i think i found a solution. instead of assocciating a widget to the name of a variable, as i had been thinking, instead i must associate it to the object itself. thus instead of the name, i will simply use the id. thanks guys! ~transami On Fri, 2002-07-19 at 01:40, Hal E. Fulton wrote: > ----- Original Message ----- > From: "Tom Sawyer" > To: "ruby-talk ML" > Sent: Friday, July 19, 2002 2:23 AM > Subject: Re: #name of instance > > > > opps, slight typo. not bob, but bobo: > > > > class A > > def myname > > puts self.name # ? > > end > > end > > > > bobo = A.new > > bobo.myname # OOPS > > > > producing: > > > > bobo > > Without some tremendous gyrations, > it's just not possible. > > Remember that a variable is just a > reference to an object. > > First of all, an object has no way > of knowing what variable might > reference it. > > Second, there could be any number > of variables referencing the same > object. > > toto = gogo = bobo = A.new > toto.myname # Logically, all three > gogo.myname # of these must produce > bobo.myname # the same result. > > Thirdly, there might be no variable > at all referencing the object. > > A.new.myname # What now? > > So unless you're prepared to do some > weird things to associate a name with > an object when it's created, there's > just no way. Even if you *do* that, > there are still shortcomings. > > Perhaps time to rethink. > > If you're not familiar with how Symbols > work in Ruby, go look that up. That > might give you some ideas. > > Cheers, > Hal > > > -- ~transami _(")_ dobee dobee do... \v/ ^ ^