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.
Here is a small code example: 

Still, have a question? Feel free to contact me!!

Comments

  1. Bulgarian regulation permits licensing numerous types of online games, including betting, poker and casino games. However, besides for fast lotteries, following amendments to the GA made in February 2021, online lotteries are a state monopoly. Convenience is the top factor phrases of|in relation to} the growth of the net gambling business. Most individuals, however, prefer to play online gambling games like satta king from the comfort of their houses the place they feel most relaxed. It is 카지노 사이트 advisable to examine the legitimacy of the on line casino web site earlier than putting the guess.

    ReplyDelete

Post a Comment

Popular posts from this blog

Why should I write tests?

How I started my career after graduation

The Observer Design Pattern in Ruby!!