On Wed, Aug 13, 2003 at 08:46:32PM +0900, Tim Hunter wrote: > This is the practice that RMagick follows. Each attribute accessor that > accepts a constant has code that tests the input argument against the list > of valid values. > > That, however, does not prevent somebody from assigning a constant with a > correct value but incorrect name. For example, if APPLES = 3 then > miter_line_join would happily accept APPLES as an argument. > > I don't regard this as a major problem. Nor would I; but if it were a concern you could use symbols instead, and a hash to map to the correct constant value. class MyClass LINES = { :thin => 1, :thick => 2, :monster => 3, } def self.set_line_size(x) @@line_size = LINES[x] || (raise "Bad value") end end MyClass.set_line_size(:thick) Regards, Brian.