From: Hugh Sasse Staff Elec Eng Date: 2001-11-23T01:24:33+09:00 Subject: [ruby-talk:26154] Re: Passing class names to constructors. On Fri, 23 Nov 2001, Dave Thomas wrote: > Hugh Sasse Staff Elec Eng writes: > > > class TangledRope > > def initialize(knotclass = :Knot) > > mess = Array.new() > > (10*rand()).times do { > > mess.push(knotclass.something.new()) > > If instead of passing in the symbol, you passed the class itself, you > could just do: > > mess << Class.new(knotclass) Can I do this if I have already defined class Knotclass? The intention is to allow users to define their classes with conventional subclassing, and then pass these subclasses into my constructor. So I'm thinking that: > > Does the symbol buy you anything here? what it buys me is not doing Class.new(Knotclass) where Knotclass is *already* defined. > > > Dave > Hugh