课程: Treating Go as an Object-Oriented Language

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Structs as classes

Structs as classes

- [Instructor] Go is not an object-oriented language as I just stated. But the first similarity that we can leverage while treating Go as a pseudo object-oriented language is through the use of structs as classes. Now, let's first talk about a class in OOP. My assumption here is that you have familiarity with the paradigm, so I will keep this very high level. At its core, a class is a template for an object. A class has attributes or variables that are part of the object when it is created. A class also has methods or functions, and these procedures can act on the data within the class within that object or can act external to that. And while many languages provide classes, they all ultimately are user defined even if that user was one of the core library developers. So classes other than the base class are always user defined. So let's talk about Go structs and how they're similar to classes. Go structs, like classes are…

内容