"Markus Jais" <info / mjais.de> wrote: > Hello > > I have this code: > > country = Struct.new("france".intern, :person) > person_class = Struct.new("person".intern) > > > meth = <<-METHOD > def method > @person = @person_class.new > end > METHOD > > country.class_eval(meth) > > c = country.new() > c.method() > > > this is my error message: > ./temp.rb > (eval):2: warning: instance variable @person_class not initialized > (eval):2:in `method': undefined method `new' for nil (NoMethodError) > from ./temp.rb:17 > > > the one that bothers me is the first one with "@person_class not > initialized" > > is it possible to do this ?? I am not sure if this could work at all. > I also tried > "@person_class.name" + ".new" > > but @person_class.name does return an empty string. > > any ideas > > Thanks in advance > > Markus I thought Mauricio was going to take your head off ;-) (SIG_ORANGE_ALERT:) Country = Struct.new(:name, :person) Person_class = Struct.new(:person) Country.class_eval(<<-METHOD) def method p [name, person] p Person_class.new('someone') end METHOD c = Country.new('France', 'Guy') c.method() class Country def method_2 p Person_class.new('someone else') end end c.method_2 daz