Search code examples
scalaakkaactor

How to get an ActorRef from "this"


Lets say you have an actor class:

class MyActor extends Actor { }

And somewhere within MyActor, you'd like to pass it to another actor. But, you need "this" as an ActorRef. Since "this" is of type Actor, it can not be passed where ActorRef is required.

So the question is, how can an Actor ("this") get a reference to itself as an ActorRef? Is this even possible, or am I totally misunderstanding something...


Solution

  • From an Actor you can use self to get the ActorRef