From: dblack@... Date: 2006-07-21T06:30:52+09:00 Subject: Re: Problem when 'loading' a file containing a class derived from a struct Hi -- On Fri, 21 Jul 2006, Chris Roos wrote: > I actually spotted this in a rails app but traced it back to ruby. Is > this a real problem/bug or am I missing something obvious? > > $ cat > person.rb > class Person < Struct.new(:forename, :surname) > end > $ irb > irb> load 'person.rb' > => true > irb> load 'person.rb' > TypeError: superclass mismatch for class Person > from ./person.rb:1 > from (irb):2 > > This behaviour has been experienced with both ruby 1.8.2 and 1.8.4. It's because you're trying to give Person a new superclass: Struct.new gets called again when you reload the file. David -- http://www.rubypowerandlight.com => Ruby/Rails training & consultancy http://www.manning.com/black => RUBY FOR RAILS (reviewed on Slashdot, 7/12/2006!) http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log dblack@wobblini.net => me