Search code examples
scalaakkaactor

scala doesn't like self variable in akka?


import actors.Actor
import akka.actor.Actor._
class HelloWorldActor extends Actor {
  def receive = {
    case msg => self reply (msg + "world")
  }
}
remote.start("localhost",9999).register(
  "hello-service", actorOf[HelloWorldActor]
)

I'm getting the follow error with my code: error: not found: value self


Solution

  • Well, that's because you've imported Scala Actors:

    actors.Actor

    and then try to create an instance of it using Akka.

    If you change:

    actors.Actor

    to

    akka.actor.Actor

    everything will be just fine.