Different Between Include and Extend in Ruby 2016-11-17 2:35 pm | Comments Example 1module AAA 2 def aaa 3 puts "aaa" 4 end 5 6 def self.bbb 7 puts "bbb" 8 end 9end 10 11class C1 12 include AAA 13end 14 15# C1.bbb # undefined method `bbb' for C1:Class 16# C1.aaa # undefined method `aaa' for C1:Class 17C1.new.aaa # aaa 18# C1.new.bbb # undefined method `bbb' for #<C1:0x007ff1f414af08> 19 20class C2 21 extend AAA 22end 23 24# C2.bbb # undefined method `bbb' for C2:Class 25C2.aaa # aaa 26# C2.new.aaa # undefined method `aaa' for #<C2:0x007f86ea943298> 27# C2.new.bbb # undefined method `bbb' for #<C2:0x007fc463117270>