From: rubisher Date: 2008-05-25T05:49:34+09:00 Subject: Re: Is it possible from a class to grab the name of the object instance? Phillip Gawlowski wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > rubisher wrote: > > | The idea was that as far as ruby is interpreded, it have to save > | variable name somewhere in clear with its id and for debuging reason it > | could be accessible somehow. But ok it's not possible and for me it's > | just nice to know. > > Well, you could modify your MyClass#initialize method to do something > similar. > > Add a global variable or something similar, and add the object to this > variable (for example a Hash, with the variable name as key, and the > object's class as value). > Good, very good idea, I will investigate. > Though, you'd have to intercept the assignment somehow to grab the > variable name. > Thanks a lot, r. > HTH, > - -- > Phillip Gawlowski > Twitter: twitter.com/cynicalryan > Blog: http://justarubyist.blogspot.com > > Format a program to help the reader understand it. > ~ - The Elements of Programming Style (Kernighan & Plaugher) > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.8 (MingW32) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkg3bS8ACgkQbtAgaoJTgL/bPwCfRra/JfzsjjD5XS9cRXdB7Ede > RRUAn3eYv1QZQnWHIIzVixr1hm1eDwUR > =vkQ1 > -----END PGP SIGNATURE----- > >