Go Inheritance and Polymorphism

From NovaOrdis Knowledge Base
Revision as of 21:33, 4 August 2024 by Ovidiu (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

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 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: