Trying to write an alternative Hello World using Scala and Akka
I have little previous experience with deprecated Scala actor, recently I
started to learn Akka actor, they seem to be quite different.
I completed this tutorial
http://doc.akka.io/docs/akka/2.2.0/scala/hello-world.html
Next, I am trying to write an alternative Hello World, using a paradigm
similar to deprecated Scala actor. But I have some difficulties (see
in-line comments):
class Echo extends Actor {
override def receive = {
case a: Any => println(a)
case "end" => context.stop(self)
}
}
object Main {
def main(args: Array[String]): Unit = {
val echo = new Echo()
// Where is explicit Actor.start() ?
// "! is not a member", but Akka's official Hello World used ! to send
message
echo ! "Hello"
echo ! "end"
}
}
No comments:
Post a Comment