[Ruby] Module

module

--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.

Modules and inheritance

--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 **.

Non-instantiability

--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.

Namespace

--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.

reference

-First Ruby

Recommended Posts

[Ruby] Module
About Ruby Kernel Module
What is a Ruby module?
[Ruby] Get parent module (moved)
[Java] Module
[Ruby] Array
Ruby basics
Ruby learning 5
Ruby basics
Ruby Review 2
Ruby addition
Ruby learning 3
Ruby setting 2
Ruby problem ⑦
Ruby learning 2
[Ruby] Block
Refactoring Ruby
ruby calculator
Ruby settings 1
Refactoring Ruby
Ruby learning 1
Ruby Review 1
Introduction to Ruby 2
Ruby input / output
ruby Uppercase letters
ruby search problem
Ruby Learning # 25 Comments
ruby constant variable
Ruby to_s method
[Ruby] postfix if
[Ruby] FizzBuzz problem
Ruby text conversion
Ruby basic terms
Ruby Learning # 13 Arrays
About Ruby symbols
Ruby Learning # 1 Introduction
Ruby Learning # 34 Modules
[ruby] drill output
I started Ruby
ruby API problem
Ruby vertical writing
About ruby ​​form
[ruby] drill output
About Ruby Hashes
Ruby setting 3 Rubocop
Ruby Learning # 14 Hashes
[ruby] drill output
[Ruby] each nested
[Ruby] Arithmetic progression
JDK9 Incubator Module
[Ruby] FizzBuzz problem
Class in Ruby
[Ruby] slice method
Ruby standard output
[Ruby] end_with? method
[Ruby] Method memorandum
Chart type Ruby
[Ruby] Hash retrieval
Basics of Ruby
[WIP] Ruby Tips
[ruby] drill output