使用返回 Either[Fail, TupleX] 的表达式,我如何折叠结果而不必在成功块中定义本地 val?
// returns Either[Fail, Tuple2[String, String]]
val result = for{
model <- bindForm(form).right
key <- dao.storeKey(model.email, model.password)
} yield (model.email, key)
result fold (
Conflict(_),
tuple2 => { // want to define email/key on this line
val(email,key) = tuple2
...
}
)