为什么Kotlin不会在Hamkrest中自动将KFunction1转换为Matcher?
看看Hamkrest的github,其中包括:为什么Kotlin不会在Hamkrest中自动将KFunction1转换为Matcher?,kotlin,hamcrest,Kotlin,Hamcrest,看看Hamkrest的github,其中包括: fun isRipe(f: Fruit): Boolean = f.ripeness >= 0.5 fun isCookingApple(a: Apple): Boolean = a.forCooking ... val mA: Matcher<Apple> = ::isRipe and ::isCookingApple fun isRipe(f:Fruit):布尔值=f.summess>=0.5 有趣的是煮苹果(a:App
fun isRipe(f: Fruit): Boolean = f.ripeness >= 0.5
fun isCookingApple(a: Apple): Boolean = a.forCooking
...
val mA: Matcher<Apple> = ::isRipe and ::isCookingApple
fun isRipe(f:Fruit):布尔值=f.summess>=0.5
有趣的是煮苹果(a:Apple):布尔=a
...
val mA:Matcher=::isRipe和::isCookingApple
但是,当我复制此代码时,会出现编译器错误:
错误:(42,45)Kotlin:类型不匹配:推断的类型不匹配
KFunction1
但是Matcher
是
期望
为什么?对我来说,这很有效。。。您是否导入了错误的
和扩展名或其他内容?