您好我有两个期货FutureA和FutureB我想从FutureB取一个值,在FutureA使用它,但所有我得到是空 这里是代码如何在外部将来在Scala中使用内未来价值
futureA = ask(ActorA, MessageA).mapTo[Int]
FutureB = ask(ActorB, MessageB).mapTo[Int]
var someResult=0
futureA.map {
result =>
FutureB.map { x =>
someResult=x//suppose it will retun 5
}
someResult=someResult+1//it should give 6
println(someResult)//here i am getting 1
}
我想someResult
返回6
但它返回1
我怎么能做到这一点 我不想使用阻塞调用await.result
是的,它确实感谢很多 – swaheed