[英]mapAsync type mismatch; found : Unit required: scala.concurrent.Future
My this piece of code complaining about type mismatch; found: Unit required: scala.concurrent.Future
我的这段代码抱怨
type mismatch; found: Unit required: scala.concurrent.Future
type mismatch; found: Unit required: scala.concurrent.Future
, whereas I am returning a Future
. type mismatch; found: Unit required: scala.concurrent.Future
,而我返回的是Future
。 I am very new in Scala not sure what I am missing here .我是 Scala 的新手,不确定我在这里缺少什么。
val records: List[CommittableRecord[Either[Throwable, MyEvent]]] = ???
records.mapAsync(1){ x =>
val res = (x.value match {
case Right(event:MyEvent) =>
val future = getTask(event.get("task").getOrElse(""))
//future => Future[Try[Int]]
val k = future.map {
case Success(value) => value
case Failure(exception) => 0
}
//k => Future[Int]
})
}
变量赋值返回Unit
,只需删除val k =
或将k
放在最后
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.