问题
Hi I have two examples below within the receive method of an actor:
First one does not cache the sender actor for piping
val futureV = //Some function call that returns a Future
futureV.pipeTo(sender)
Second one takes the sender in a val first
val currentS=sender
val futureV = //Some function call that returns a Future
futureV.pipeTo(currentS)
My question is which one is the correct way to code and why?
回答1:
They are the same. The sender is not going to change. pipeTo
takes its argument by value, not by name.
来源:https://stackoverflow.com/questions/33858051/how-to-use-pipeto-in-akka-correctly