Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/18.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
Scala 无法应用参数化的curried函数_Scala_Currying - Fatal编程技术网

Scala 无法应用参数化的curried函数

Scala 无法应用参数化的curried函数,scala,currying,Scala,Currying,我有一个函数,它有以下定义: def expectMsgPF[T](max: Duration = Duration.Undefined, hint: String = "")(f: PartialFunction[Any, T]): T = { 当我这样称呼它时: val res1 = listener1.expectMsgPF(1.second) res1是一种功能吗 我想写如下: val res1 = listener1.expectMsgPF(1.second) _ val r

我有一个函数,它有以下定义:

def expectMsgPF[T](max: Duration = Duration.Undefined, hint: String = "")(f: PartialFunction[Any, T]): T = {
当我这样称呼它时:

val res1 = listener1.expectMsgPF(1.second) 
res1
是一种功能吗

我想写如下:

 val res1 = listener1.expectMsgPF(1.second) _
 val res2 = listener2.expectMsgPF(1.second)
 Then("it should contain `Kafka and SAP are offline`")
 res1 {
    case status: ServerStatus =>
    status.health should be(ServersOffline)
  } 

但是它不起作用。

要使
res1{case status:ServerStatus=>status.health应该是(ServersOffline)}
起作用,请尝试向
expectMsgPF[T]
提供类型参数
T
来帮助编译器

val res1 = listener1.expectMsgPF[Assertion](1.second) _
这使得
res1
确实是该类型的函数

PartialFunction[Any, Assertion] => Assertion

expectMsgPF
是一种方法,而不是函数。-<如果预期类型为函数,则代码>res1可以是函数。