From: Chris Morris Date: 2002-04-15T02:31:31+09:00 Subject: RE: inspect object attributes > i need a method like this > > obj = Obj2.new > inspect obj -> ['val1', 'val2', 'val3', 'val4'] I believe obj.instance_variables will do what you want. One caveat, in your example, attr_accessor doesn't actually create the instance variable until it's been used. So: obj = Obj2.new puts 'vars = ' + obj.instance_variables.inspect -> vars = [] but: obj = Obj2.new obj.val1 = 4 obj.val2 = 5 obj.val3 = 6 obj.val4 = 7 puts 'vars = ' + obj.instance_variables.inspect -> vars = ["@val4", "@val3", "@val2", "@val1"]