June 2017
Beginner
330 pages
7h 30m
English
Polymorphism occurs when the PhoneConnector class overrides the behavior of api_logger method, like in the following code:
class PhoneConnector < ApiConnector def api_logger puts "Phone call API connection starting..." endendphone = PhoneConnector.new(title: 'My Title', description: 'Some content')phone.api_logger
Now, if you run the same code, it prints Phone call API connection starting... .
This type of polymorphism implementation is quite common in Ruby development and helps developers give some custom behavior to an application.
Next: what happens when we want to combine the behavior from the api_logger method of both the ApiConnector and PhoneConnector classes?
To do that, simply insert the super word ...
Read now
Unlock full access