From: Tom Sawyer Date: 2003-01-26T13:30:59+09:00 Subject: Re: Reflection for instance variables? On Saturday 25 January 2003 08:34 pm, Patrick Narkinsky wrote: > Hi. I'm brand new to Ruby, so please pardon if this question is naive, > but I have not been able to figure it out. I would like to come up with > a way to define a method in a superclass that would give me a list of > variables in a subclass. So: dont think a class method is going to cut it, for a couple of reasons. but perhaps this: class Father @h_test = "1234" @h_test2 = "12345" def vars return self.instance_vars - self.superclass.instance_vars end end class Son < Father @h_test3 = "123456" end s = Son.new print s.vars NOT TESTED!!! > (For the curious, I'm trying to do something in Ruby I saw in > objective-c. This class allowed you to define a subclass, define the > variables in the subclass, then it would create the sql, etc. > automagically.) sounds fun! and good luck. -- tom sawyer, aka transami transami@transami.net