In fact, go objects are far-fetched. In fact, it is interface-oriented. Interface-oriented .. Ha, this is the object-oriented statement. But he is not the object-oriented interface-oriented programming.
The Go interface is similar to an object-oriented generic type. Remember that it is a type. Can be assigned a value. can be assigned a value. But it is also an interface. However, this interface is different from the previously used object-oriented interface. You must define the interface and then implement the interface using the class. The idea of the Go interface is the opposite, which is equivalent to the method of this class. Then we define an interface, which methods are available for this interface. Then this type can be assigned to this interface. That's simple.
Maybe you don't understand.CodeRight:
Type testinterface interface {
Add (a, B INT) int
Multiply (a, B INT) int
}
All types that implement the ADD and multiply methods can be directly assigned to the testinterface type variable.
In addition, the interface can be used as a response when your parameter is water or the type of the returned value is uncertain.
In other go statements, only classes are supported. In upper case, the function can be accessed by an external package. In lower case, this function can be viewed and used only in the package.
Play. After reading this for a long time, nothing can be written. Bytes
next time, start with the development website! OK