The following class raises an error in the new HelloWorld line:
Exception in thread "main" akka.actor.ActorInitializationException: You cannot create an instance of [HelloWorld] explicitly using the constructor (new). You have to use one of the 'actorOf' factory methods to create a new actor. See the documentation. at akka.actor.ActorInitializationException$.apply(Actor.scala:219) at akka.actor.Actor$class.$init$(Actor.scala:436) at HelloWorld.<init>(HelloWorld.scala:4) at Driver$.main(HelloWorld.scala:38) at Driver.main(HelloWorld.scala)
So I'm trying: val hw = actorOf(new HelloWorld) But this causes a compiler error:
not found: value actorOf
How to implement HelloWorld below?
Reading other Scala docs requires the action method to be defined inside a class that extends Actor and then calls the start method in that class, is there any reason to use actorOf instead of defining an action method?
The following class is taken from Scala akka docs http://doc.akka.io/docs/akka/2.2.0/scala.html :
import akka.actor.Actor import akka.actor.Actor._ import akka.actor.Props class HelloWorld extends Actor { override def preStart(): Unit = {
source share