From: Robert Klemme Date: 2011-08-13T20:20:07+09:00 Subject: Re: How to get the Name of a Variable On Sat, Aug 13, 2011 at 12:53 PM, Agent Mulder wrote: >> I suppose I'd have to ask why this is necessary. If you need a name >> associated with a value I'd recommend using a hash instead. Technically >> there might be a way be analyzing stack frames, but that would require >> access to the internals through the C API. > > I need it because I generate a complex data structure from more simple > primitives. Having the names around makes it easier to get the desired > results. What exactly are "the desired results"? Can you elaborate a bit more on what you do? Also a http://sscce.org/ might help. > Using hashes will work, but it adds noise to the algorithms, > making them harder to construct. But if a hash is the simplest way of > getting what I want, then a hash it will be... Usually if you have dynamic in a way that you generate names of variables from input then a Hash or similar data structure which actually stores names and values is the best. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/