Admirable 技术博客
  • 主页
  • Python
  • 工程
  • 运维
  • 作者
  • 关于
  • 生活博客
Sign in Subscribe

Go 语言

A collection of 1 post
为什么 []MyType 不是 []interface{} 的子类型?
Go 语言

为什么 []MyType 不是 []interface{} 的子类型?

在一个平凡的工作日,我尝试将一个自定义类型的 slice([]MyType)赋值给一个接收 []interface{} 类型参数的函数。然而 IDE 却告诉我不能这样使用。乍一看,interface{} 是 MyType 的父类型,那么 []interface{} 自然也应该是 []MyType 的父类型,合情合理。那么问题在哪呢?
26 Nov 2021 5 min read
Page 1 of 1
Admirable 技术博客 © 2025
Powered by Ghost