From: "David A. Black" Date: 2005-08-04T09:11:05+09:00 Subject: Re: strange: 'super' is not the parent class Hi -- On Thu, 4 Aug 2005, Gioele Barabucci wrote: > When I try to run the attached code (ar2.rb) with ruby 1.8.2 I get the > following error: > > ../ar2.rb:41:in `packDecl': undefined method `packDecl' for > "\000\000\000\005\000\000\000\002":String (NoMethodError) > from ./ar2.rb:27:in `pack' > from ./ar2.rb:54 > from ./ar2.rb:49:in `each' > from ./ar2.rb:49 > > It seems like "\0\0\0\5\0\0\0\2".packDecl is called instead of > super.packDecl. Did I overwrite 'super'? Where? > > def packDecl > length = @typeDataLength + @payloadLength > return [length, @type].pack("LI") > end [...] > > def packDecl > @typeDataLength = [@name].pack("a*").length > return super.packDecl > end super here calls the previous packDecl, which returns a string. You then call the method packDecl on that string -- which is where you get the undefined method error. I think you just want "super" here, not "super.packDecl". David -- David A. Black dblack@wobblini.net