Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么Kotlin不会在Hamkrest中自动将KFunction1转换为Matcher?_Kotlin_Hamcrest - Fatal编程技术网

为什么Kotlin不会在Hamkrest中自动将KFunction1转换为Matcher?

为什么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

看看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:Apple):布尔=a
...
val mA:Matcher=::isRipe和::isCookingApple
但是,当我复制此代码时,会出现编译器错误:

错误:(42,45)Kotlin:类型不匹配:推断的类型不匹配
KFunction1
但是
Matcher
是 期望


为什么?

对我来说,这很有效。。。您是否导入了错误的
扩展名或其他内容?