From: matz@... (Yukihiro Matsumoto) Date: 2003-02-20T08:48:55+09:00 Subject: Re: How to test for existence of instance variable? Hi, In message "Re: How to test for existence of instance variable?" on 03/02/20, Brian Candler writes: |> Foo = Class.new(super) { |> def foo |> ... |> end |> ... |> } | |But then its name is fixed in the code as 'Foo'? What if the name I want to |give to the class is in the string object 'klassname'? (Actually probably |not important, as I'd be better to create an anonymous class and hold onto a |reference to it rather than use it by name, but I'd still like to know :-) Object.const_set(klassname, Class.new(super){...}) |Is the above example for Ruby 1.8+? I can't get it to work under 1.6.8, and |the Pickaxe doesn't say anything about Class.new taking a block argument: Yes. matz.