Go:interface
interface 接口
go:interface{}、断言与类型转换
- Go 的接口更大的作用是声明方法集合,而非类型约束。
- interface{}可用于向函数传递任意类型的变量,但对于函数内部,该变量仍然为 interface{}类型(空接口类型),故必须进行类型断言确认类型后检查才能使用(不能直接隐式转换)。
- 接口类型向普通类型的转换称为类型断言(运行期确定)。
| Item | Contact |
|---|---|
| Author | Jaco Liu |
| ljqlab@163.com | |
| laulinux | |
| 404691073 | |
| Blog | https://www.wdft.com |