13. Imitating Multiple Inheritance Sort by Relevance mystery 25


#1

I’m getting some output I cannot explain. This is my code:

module MartialArts
  def swordsman
    puts "I'm a swordsman."
  end
end

class Ninja
	include MartialArts
  def initialize(clan)
    @clan = clan
  end
end

class Samurai
	include MartialArts
  def initialize(shogun)
    @shogun = shogun
  end
end

jack = Samurai.new("Jack")
puts jack.swordsman
flex = Ninja.new("Flex")
puts flex.swordsman

And it outputs:

I'm a swordsman. 25 I'm a swordsman. 25

Where in the world are those 25s coming from? Is this just an error?

Thanks


#2

i ran your code here:

https://repl.it/@stetim94/PositiveInferiorGuanaco

and it works fine, seems to be related to codecademy


#3

Thank you it had me very confused.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.