package
Version:
v0.0.0-...-9d91cd3
Opens a new window with list of versions in this module.
Published: Oct 15, 2020
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Test1 practice 1
The way to Go 接口练习
Test2 practice 2
类型断言 判断接口是什么类型
接口就是一个动态类型,即在运行时才检查它的实际类型。
Test3 practice 3
类型判断 type-switch
type-switch 不允许有 fallthrough
Test4 类型断言中的特例,判断该值的类型是否实现了接口。
Test5 作用于接口变量上的方法和作用于变量上的方法是不同的。
接口变量中存储的值是不可以寻址的。
type Appender interface {
Append(int)
}
Appender .
type Lener interface {
Len() int
}
Lener .
Name 实现 Nameable 接口看下接口类型的变量在内存中的存储
是否是按照对应类型的值和自动反射出来的方法
type Options interface {
}
Options 可选参数接口
type Sorter interface {
Len() int
Less(i, j int) bool
Swap(i, j int)
}
Sorter interface
接口中 i,j 表示的是下标
Source Files
¶
Click to show internal directories.
Click to hide internal directories.