Let's say I have an interface Base
and that we implement that interface in class Base1 : Base
.
我希望表单中有一个扩展函数
fun ArrayList<Base>.myFun()
to also work on arrayListOf(Base1(), Base1()).myFun()
, but it doesn't. It requires the list to be of type Base
instead of Base1
.
这不是很奇怪吗?或者我只是错过了什么?
And, what are my options to write a function available on all subclasses of an interface?
谢谢!