Go Inheritance and Polymorphism: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * Go Object Oriented Programming =Overview= =Inheritance= ==Polymorphism== Polymorphism is available in Go, but it is implemented differently than in other object-oriented languages. In other OOP languages, there is a formal <code>extends</code> language keyword or other formal syntax that expresses the inheritance relationship between classes. In Java, the inheritance is formally decla...")
 
Line 3: Line 3:
=Overview=
=Overview=
=Inheritance=
=Inheritance=
==Polymorphism==
=Overriding=
=Polymorphism=
Polymorphism is available in Go, but it is implemented differently than in other object-oriented languages.  
Polymorphism is available in Go, but it is implemented differently than in other object-oriented languages.  



Revision as of 21:39, 4 August 2024

Internal

Overview

Inheritance

Overriding

Polymorphism

Polymorphism is available in Go, but it is implemented differently than in other object-oriented languages.

In other OOP languages, there is a formal extends language keyword or other formal syntax that expresses the inheritance relationship between classes. In Java, the inheritance is formally declared with the extends keyword:

class SomeSubclass extends SomeSuperclass {
  ...
}

In Python, we formally declare that a class extends other class with this syntax:

class SomeSubclass(SomeSuperclass):
  ...

o, in that it does not imply formal inheritance at language level, which is not available in Go. Polymorphism in Go is implemented using interfaces.

For a generic discussion on polymorphism, see:

Object-Oriented Programming | Polymorphism

Overriding

Example

Inheritance and Polymorphism Example

TO DEPLETE

Read and merge into document: