You have object class, I have structure, Go lang1.18 introductory refining tutorial, from Bai Ding to Hongru, the use of go lang structure (struct) EP06

Original link: https://v3u.cn/a_id_229

Continuing the previous article, at the object-oriented level, Python has achieved super god: everything is an object, while Ruby is simply a god: flying flowers and leaves can be objects. Both provide object-class operations and inheritance methods for object-oriented purposes, but Golang obviously has some unique features, because it has no traditional classes and no inheritance. Instead, it uses structures and combinations, that is, structures. (struct) way to organize the code to achieve a class-like effect. The declaration of the structure struct In Golang the following syntax is used for the declaration of the structure: typestruct_namestruct{attribute_name1attribute_typeattribute_name2attribute_type…} Suppose a structure named Lesson (course) is defined…

This article is reprinted from: https://v3u.cn/a_id_229
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment