从单位到未来的类型转换[布尔]

时间:2015-11-12 20:32:19

标签: scala silhouette

我有以下功能,我想返回A,但IDE会提示我返回Sub ArrayDemo() Dim A(10 ^ 6) As Integer Dim B(10) As Integer For i = 0 To 10 ^ 6 A(i) = Round(Rnd * 10, 0) Next Start = GetTickCount k = 0 For i = 0 To 10 ^ 6 For j = 0 To k If B(j) = A(i) Then GoTo nxt Next B(k) = A(i) Debug.Print B(k) k = k + 1 nxt: Next Debug.Print GetTickCount - Start End Sub 。我是Scala的新手。有人能指出我做错了吗?

Future[Boolean]

1 个答案:

答案 0 :(得分:2)

onSuccess替换为flatMap。假设您的remove(x: String)方法也返回Future,那么还需要flatMap ped:

def remove(loginInfo: LoginInfo): Future[Boolean] = {
  val result = findObject(loginInfo)

  result.flatMap {

    case Some(persistentPasswordInfo) =>

      val removeResult = remove(persistentPasswordInfo._id.toString)

      removeResult.flatMap {
        case Left(ex) => Future.successful(false)
        case Right(b) => Future.successful(b)
      }
    case None => Future.successful(false)

  }

}