我有这个代码,我陷入了switch case语法和未来:
def getAll(implicit queryParams: QueryParams): Action[AnyContent] =
securityService.authenticate() { implicit request =>
withErrorRecovery { req =>
toJson {
repository.getAll(request.user.loginName).flatMap {
xyz =>
Future.sequence(xyz.map {
abc =>
if (abc.roleName != " ") { // getting error
case Some(abc) => repotosecondquery.getrepo()
}
case None =>
Future.failed(new
RuntimeException(NotFoundException()))
})
}
}
}
}
答案 0 :(得分:0)
尝试将xyz
更改为case xyz
。
顺便说一下,它是模式匹配,而不是切换案例。