You can also use "unbecome" and effectively treat an actor's behavior as a stack, popping and pushing receive functions. One cool trick is to bind a value to your receive function:
def receive(foo: Foo): Receive = { ... }
Then you can bind immutable data to a given receive function but think of it as mutable by replacing the current receive function with become().
Smalltalk also is rather famous for giving developers enough freedom to more or less destroy the environment with the terrifying looking command "Smalltalk := nil"
It's actually pretty cool if you think of it as a way to track state without having a mutable variable.
One example is this implementation of the dining philosophers problem:
https://github.com/akka/akka/blob/master/akka-samples/akka-s...
You can also use "unbecome" and effectively treat an actor's behavior as a stack, popping and pushing receive functions. One cool trick is to bind a value to your receive function:
Then you can bind immutable data to a given receive function but think of it as mutable by replacing the current receive function with become().