Sean O'Halpin wrote: >> > Use a constant: > > class REXML::Element > INLINE = %w(a b code em emphasis i strong tt) > def inline? > INLINE.member?(name) > end > end > Yup. Another good alernative. Do I then I share that constant with the surrounding program like this: INLINE = REXML::Element::INLINE It would be better to access the constant defined in my class: class Main INLINE = %w(a b code em emphasis i strong tt) attr_reader :INLINE class REXML::Element def inline? return Main.INLINE.member?(name) end end end But that doesn't seem to work.. error: in `inline?': undefined method `INLINE' for MY_MODULE::Main:Class (NoMethodError) > BTW > >> Coming from the Java world, I >> just assumed that this would be legal: >> class Foo >> @bar = 2 >> end >> >> But it isn't. > > It is, it just doesn't do what you were expecting. Instead of > initialising an instance variable belong to an instance of the class, > it initialises an instance variable belonging to the instance of Class > that is the class definition. A class is an object too. > Ah ha! I knew it was there when the class is being read, but not when the object is constructed. I didn't quite realize that it is still there as part of the class definition. That helps to refine my mental model. Thanks much.