1.

What is the difference between a class and a module?

Answer»
CLASS
Module
Classes are about CREATING objects.
Modules are more about providing methods that can be used across DIFFERENT classes. You can relate modules with libraries which can be included in classes.
A class can be instantiated.
Modules cannot be instantiated.
A class can create objects.
Modules provide a mixin FEATURE and namespace.
Class has class methods and instance methods.
Module has module methods and instance methods.
Class cannot be included in other class or module.
Module can be included in other modules or classes
Class can be extended with inheritance.
Module is extended with ‘extend’ keyword.


Discussion

No Comment Found