What is the difference between exclamation mark (!
) and question mark (?
) when sending messages to Actors?
myActor ! Hello(value1)
myActor ? Hello(value1)
Shamelessly copied [awesome] official doc (look Send messages section for more):
Messages are sent to an Actor through one of the following methods.
!
means “fire-and-forget”, e.g. send a message asynchronously and return immediately. Also known astell
.
?
sends a message asynchronously and returns aFuture
representing a possible reply. Also known asask
.