From: "Xavier R." Date: 2013-02-28T06:56:04+09:00 Subject: Re: Object track llist for a particular class. Ryan Victory wrote in post #1099432: > Hans, > > Hash[local_variables.map {|k| [k,eval(k.to_s)]}].inspect.scan(/(?:\{| > )\:([^=]+)\=/).flatten > > Love U Ruby, that should return for you the instances in the form of > ["a","b"] in your example. > > -Ryan It gives the below: >> class Test >> end => nil >> foo = Test.ne NoMethodError: undefined method `ne' for Test:Class from (irb):12 from /usr/bin/irb:12:in `
' >> foo = Test.new => # >> bar = Test.new => # >> Hash[local_variables.map {|k| [k,eval(k.to_s)]}].inspect.scan(/(?:\{| )\:([^=]+)\=/).flatten => ["bar"] Not ["foo","bar"] -- Posted via http://www.ruby-forum.com/.