From: Rick DeNatale Date: 2007-10-26T20:58:01+09:00 Subject: Re: find all member in a class On 10/26/07, Pokkai Dokkai wrote: > how to find all members list(member functions & member variables for all > access specifiers like public, private and protected) ? > -- > Posted via http://www.ruby-forum.com/. > > Note that unlike some languages with which you might be familiar, "member" variables aren't declared and only come into being when defined during code execution. In fact there's a real difference between that subtle vocabulary shift between "member" and "instance". Different instances of the same class might have different sets of instance variables. In fact the same instance might acquire instance variables over time: class A def i @i ||= 42 end def j @j ||= "hello" end end a1 = A.new a1.instance_variables # => [] a1.i a1.instance_variables # => ["@i"] a1.j a1.instance_variables # => ["@j", "@i"] AND, since Ruby allows instances to have singleton methods, it's even possible for two instances of the same class to have different sets of methods. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/