Quotes help make search much faster. Example: "Practice Makes Perfect"

Tuesday, January 22, 2013

Codecademy Sample Solution: Imitating Multiple Inheritance



# Create your module here!
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

#test
Leo = Ninja.new("Tutle")
Leo.swordsman

Himura = Samurai.new("Hogan")
Himura.swordsman

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts