From: "Hal E. Fulton" Date: 2001-11-18T10:10:17+09:00 Subject: [ruby-talk:25735] Parametric classes I'm in the awkward position of having written some code months ago and then forgotten the underlying principle. I was trying to "parameterize" classes and set class variables appropriately. This is a fragment that I got to work... but, reading it, I feel as if it were someone else's code. :0 The confusing part is passing in the parent class to Class.new -- this is a parameter to the initialize method, but it's not used in my code. Can someone comment on how this works? Hal class Class def initialize(parent,&block) class_eval(&block) end end class Nationality def Nationality.native_lang class_eval("@@native_lang") end def Nationality.native_lang=(x) class_eval("@@native_lang = #{x}") end #... end Australian = Class.new(Nationality) do @@native_lang = "English" end Brazilian = Class.new(Nationality) do @@native_lang = "Portuguese" end t = Australian.new p Australian.native_lang # "English" p Brazilian.native_lang # "Portuguese" p t.class # Australian p t.is_a? Nationality # true