--Something like a "class that can't be instantiated".
--The Class
class is a subclass of the Module
class.
--"Class = module + instantiation capability"
Mix-in
--Restricted multiple inheritance
--Ruby can only inherit one class.
――Ruby can inherit any number of modules that are "like a class but not a class".
--Calling a class inheriting a module include
.
--The include
module will appear in the class's ancestors
method.
-** When a class include
a module, you get an instance method of the module **.
--Modules cannot be instantiated. --Mix-in is just a "topping". It is a "module" for providing an implementation according to the main class, not a concrete object.
--Classes with the same name belonging to different namespaces are treated differently even if they happen to have the same name. --In Ruby, it is customary to use modules to provide namespaces.
Recommended Posts