如何在Scala中使用开关盒来满足条件?

时间:2017-10-25 11:52:32

标签: scala

我有这个代码,我陷入了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()))
            })
        }
      }
    }
  }

1 个答案:

答案 0 :(得分:0)

尝试将xyz更改为case xyz

顺便说一下,它是模式匹配,而不是切换案例。