Module - Include or Extend? and Mixin
Multiple Inheritance – A class is suppose to show multiple inheritance when that class can inherit characteristics and features from more than one superclass(parent class).
Mixin – Since Ruby does not support multiple inheritances but has an amazing implementation of achieving the same by eliminating the need for multiple inheritances using the module, is also known as the mixin.
Mixin - can be achieved by using either include or extend keywords inside a class. The difference between include and extend is:
- include : mixes in specified module methods as instance methods in the target class.
- extend : mixes in specified module methods as class methods in the target class.
Still, have a question? Feel free to contact me!!
Comments
Post a Comment