You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/syntax_and_semantics/modules.md
+4-2Lines changed: 4 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -2,8 +2,8 @@
2
2
3
3
Modules serve two purposes:
4
4
5
-
* as namespaces for defining other types, methods and constants
6
-
* as partial types that can be mixed in other types
5
+
- as namespaces for defining other types, methods and constants
6
+
- as partial types that can be mixed in other types
7
7
8
8
An example of a module as a namespace:
9
9
@@ -18,6 +18,8 @@ Curses::Window.new
18
18
19
19
Library authors are advised to put their definitions inside a module to avoid name clashes. The standard library usually doesn't have a namespace as its types and methods are very common, to avoid writing long names.
20
20
21
+
## `extend` and `include`
22
+
21
23
To use a module as a partial type you use `include` or `extend`.
22
24
23
25
An `include` makes a type include methods defined in that module as instance methods:
0 commit comments