Chapter 8 Modules

Modules are similar to classes. Both of them groups a collection of constants, variables, and so forth. Modules, however, do not have an instance and a subclass. Unlike classes, modules are defined using module ... end.

Modules provide two benefits:

  • Namespace – Modules define a namespace in which your methods and constants will not clash with other methods and constants defined elsewhere.
  • Mixin – Modules implement mixins. A mixin is a partially defined class. Through mixins, you can share the functionality between classes.

  • Currently 3.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
  Flag Inappropriate Content 0 comments