Mitul Dabhi
answered Nov 30 '-1 00:00
include and extend is look similar at first glance in ruby
but if you see more closely some minor difference.
include also include peace of code and extend do same also but
include , include it as module's methods as instance methods.
extend , include it as module's methods as class methods.
module main
def me
puts "Me module main"
end
end
class sub1
include main
end
class sub2
extend main
end
sub1.new.me is valid invoke
sub2.me is valid invoke
you can feel difference between include and extend in Ruby