Eclipse抛出异常:
type mismatch; found : scala.concurrent.Future[Any] required: scala.concurrent.Future[Boolean]
我在scala中比较新,所以我只需要返回一个布尔值,无论extractWord结果是否存在..
这段代码有什么问题?我误解了一些事情......
override def checkAccessAuthorized(implicit request: RequestHeader, context: ExecutionContext,sessionTimeoutInSeconds: Int): Future[Boolean] = {
(for {
word <- extractWord
} yield for {
Some(userId) <- cacheUtils.get(word)
_ = cacheUtils.prolongTimeout(word, sessionTimeoutInSeconds)
} yield {
Future.successful(true)
}).getOrElse {
Future.successful(false)
}
}
prolongTimeout方法的标题是:
def prolongTimeout(word: AuthenticityWord, timeoutInSeconds: Int)(implicit request: RequestHeader, context: ExecutionContext) : Unit