Go Inheritance and Polymorphism
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:
Overriding
Example
TO DEPLETE
Read and merge into document: