我想确认任何一个都是可读的
override fun funnyFunction(context: Any): Any {
if(context is Iterable)
// do something
}我得到的警告
一个类型的参数期望。如果不想传递类型参数,请使用“Iterable<*>”
在Java中,代码是
Object funnyFunction(final context: Object) {
if(context instanceof Iterable)
// do something
}有人知道怎么做吗?
发布于 2022-07-21 20:13:41
它确切地告诉你该怎么做。你需要写
if (context is Iterable<*>)仅仅因为Java的方式不同,并不意味着Kotlin会这样做。
https://stackoverflow.com/questions/73072102
复制相似问题