Consider a following snippet of code:
class MyClass {
var a = _
var b = _
...
var y = _
val z = (for {
a0 <- someMethodReturningFuture
b0 <- someMethodReturningFuture(a0)
...
z0 <- someMethodReturningFuture(y0)
} yield {
a = a0
b = b0
...
y = y0
someCalculation(y)
}).result
}
Is it possible to perform such an initialization but using vals instead of vars (somehow)? The point is, I don’t want to block and wait for every intermediate result, just for the last one.
Unless you have more than 22 variables: