Why "Class < Module" in Ruby, but I can't include class into other class? What is the technical difference between class and module except that the class can be inherited from another?
That is exactly the difference between Classes and Modules in Ruby - Modules can be included and Classes cannot. It is simply the design of the language.
Classes are intended to provide concrete functionality open for extension and Modules provide namespaces and mixin capabilities. The reason for this difference is probably related to the idea of mixins as replacement for multiple inheritance and interfaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With