2
내가 다음 코드 한
: 테스트 코드의 사실루비 믹스 : 확장 또는 포함?
module CarHelper
def call_helpline
puts "Calling helpline..."
end
end
class Car
extend CarHelper
end
class Truck
class << self
include CarHelper
end
end
# Test code
Car.call_helpline
Truck.call_helpline
모두 2 줄 작동합니다. 그래서 'extend
'과 'include
'(싱글 톤 클래스 : self
) 사이에 어떤 차이가 있습니까?
[루비에서 포함과 확장의 차이점은 무엇입니까?] (http://stackoverflow.com/questions/156362/what-is-the-difference-between-include-and-extend- 루비에서) – mliebelt