From: Todd Benson Date: 2008-01-13T21:51:24+09:00 Subject: Re: Get Variable Name from object_id On Jan 12, 2008 5:13 PM, Tim Hunter wrote: > > Evan Moseman wrote: > > If I am perusing through the each_object loop and find the objects I'm > > interested in, how can I get their variable names? > > > > Thanks! > > > > -- > > Evan > > > > You can't. Variables are just labels for objects. What if you have > something like this: > > foo = MyClass.new > bar = foo > > What's the variable name of the object? What about > > ary = [] > ary << bar > > Now what's the variable name? What about this > > def f(v) > puts v > end > > f(ary[0]) > > Now what's the variable name? I was going to reply in the same way, but I suppose it would be interesting to call up names for objects if the names exist for the object space (as nil or array for each object maybe?). Like Object#references or something like that. Todd