Unless I’ve missed the entries, I can’t find include or extend in the Ruby-Doc.org documentation or in Ruby’s keyword list. I can find obj.extend but not the extend statement used in a class definition e.g.
# add module Foo's methods as class methods of TestClass
class TestClass
extend Foo
end
or
# add module Foo's methods as instance methods of TestClass
class TestClass
include Foo
end
As a language construct, if that’s the proper term, what are include and extend and where are they defined?
It would be nice to understand just how these two statements are implemented in the Ruby language. Thanks.
extendis anObjectmethod, a convenience method forextend_object(more or less).includeis inModule, a wrapper aroundappend_features.