我不明白为什么如果不满足过滤器的条件,恢复返回空成功
case class Account(acctNum: Int, balance: Double, interestRace: Double)
def getAccount()={
Account(111,7000.0,1.2)
}
val withdrowal = 1500
val acc = Try(getAccount())
val withdrowalResult = acc map {
(x: Account) => Account(x.acctNum, x.balance-withdrowal,x.interestRace)
} filter{
(x: Account) => x.balance>8000
}recover{
case nsee: NoSuchElementException => println("Something went wrong")
}
println(withdrowalResult)
如果我打印withdrawarResult,我会得到
Success(())
如果我只是想在我的条件不满足的情况下获得失败并处理异常,我该怎么办?