Search code examples
scalaakkaactor

How to use pipeTo in AKKA correctly


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?


Solution

  • They are the same. The sender is not going to change. pipeTo takes its argument by value, not by name.