1)What is the difference between include and extend? Ans: i)Include makes the module methods are available instance of the class. 1)Not available at the class level 2)Available at the instance level ii)extend makes module methods are available class itself. 1)Not available at the class level 2)Available at the instance level here is a big difference between include and extend in Ruby. Let me show you some code to explain it : Exampl1: module Printable def self.class_method_x p 'class_method_x' end def instance_method_y p 'instance_method_y' end end — class ExtendDocument extend Printable end — class IncludeDocument include Printable end First round, on the Printable module : Printable.class_method_x # => "class_method_x" — Printable.instance_method_y # => NoMethodError: undefined method `instance_method_y' for Printable...
I love Ruby on rails.Ruby on Rails Coding is not my job its my passion ..