includeとextendの違い
内容を見ていると同じに見えてしまう。
includeとextendの動きを見てみます。
両者の違い
ソースコードで試してみます
module Greet def hello puts 'hello' end end class A include Greet end class B extend Greet end a = A.new a.hello → hello A.hello → undefined method `hello' for A:Class (NoMethodError) b = B.new b.hello → undefined method `hello' for #<B:0x007fa1691a1af0> (NoMethodError) B.hello → hello
extendは確かにそのオブジェクトにだけ特定の振る舞いを与えています。
ここがしっくり来なかったですが、上の動きを見て、違いがわかりました。