课程: Treating Go as an Object-Oriented Language
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Polymorphism
- [Narrator] Polymorphism is the last pillar we will discuss and possibly one of the ones that I use the most. And I will share with you in a bit why. So polymorphism as a whole in object-oriented programming is a very powerful construct. It gives you the ability to change behavior based on type and not the code itself. This provides a common pathway for various types that are similar to have their functionality executed without the calling method have to know what type is what and how to behave differently based on that type. It is very useful when providing these repeatable methods across a number of structs. Now, polymorphism in Go is achieved primarily through interfaces and Go Interfaces are unique in the way that they work. So Go does provide for the concept of an interface. In fact, it's nothing more than a type. It is a type of interface that is a collection of method signatures. So it's not a collection of…
内容
-
-
-
-
(已锁定)
Structs as classes2 分钟 21 秒
-
(已锁定)
Creating a struct5 分钟 16 秒
-
(已锁定)
Encapsulation2 分钟 43 秒
-
(已锁定)
Leveraging encapsulation5 分钟 35 秒
-
(已锁定)
Solution: Struct as class2 分钟 2 秒
-
(已锁定)
Composition1 分钟 36 秒
-
(已锁定)
Leveraging composition4 分钟 11 秒
-
(已锁定)
Polymorphism2 分钟 59 秒
-
(已锁定)
Leveraging polymorphism4 分钟 49 秒
-
(已锁定)
Solution: OOP4 分钟 56 秒
-
(已锁定)
-