This website collects cookies to deliver better user experience
Mixins are inheritance
Mixins are inheritance
Inheritance is getting a bad rap and rightfully so in my opinion. Inheritance has turned out to be a specialist tool for specific situations and was unfortunately overused. Long story short, try composition before inheritance.
Now, that said, I have come across developers who understand the above and yet still fall unwittingly into the trap of inheritance over-use. This happens because they think mixins are composition, but mixins are actually Ruby's answer to multiple inheritance. Don't believe me?
Here is an example of classic inheritance:
class Superclass; def talk; "world"; end; end
class Subclass < Superclass; def talk; "hello #{super}"; end; end
Now here is an example usage and a look under the hood.