TypeError: superclass mismatch for class Word in Ruby

前端 未结 4 1338
生来不讨喜
生来不讨喜 2020-12-05 17:37

I am creating a Word class and I am getting an error:

TypeError: superclass mismatch for class Word

Here is the

4条回答
  •  爱一瞬间的悲伤
    2020-12-05 18:26

    link664 has clearly explained the problem.

    However, there's an easier fix without quitting irb (and losing all your other work). You can delete an existing class definition this way.

    irb(main):051:0> Object.send(:remove_const, :Word)
    

    and you can verify with:

    irb(main):052:0> Word.public_instance_methods
    

    which should return:

    NameError: uninitialized constant Word
    from (irb):52
    

提交回复
热议问题