From: Robert Klemme Date: 2007-11-08T16:05:03+09:00 Subject: Re: define_method Please do not top post. On 07.11.2007 22:19, Malcolm Lockyer wrote: > Yes Robert, that wasn't my use case - that was just the most > simplified code that shows the problem I was having. I didn't want to > bore you all with loads of irrelevant code. If you are interested I > was trying to build a dynamic enumeration style class (vaguely similar > to java or c#'s way of doing it), where I could have the pseudo > constant (i.e. TestClass.Blue, TestClass.Red etc.) setup by calling > the constructor something like TestClass.new(:Blue => 1, :Red => 2 > etc.) and also be able to iterate through the keys and stuff. In case you are not doing it for the fun of it and / or are looking for more inspirations this is a good place to look: http://raa.ruby-lang.org/search.rhtml?search=enum Kind regards robert