Wednesday, September 16, 2015

Ruby Interview Questions : Include vs Extend

How to implement extend with include?

  
  module Laughable
    def laugh
      p 'ha ha'
    end
  end

  class Clown
    class << self
      include Laughable
    end
  end

  Clown.laugh

  class Tiger
    extend Laughable
  end


  Tiger.laugh



Click the image below to watch the video.