Where is the akka class defined?
I am new to Scala.
In one of the Actor classes, I can see that my colleague of me defines code like this
import akka.actor.Actor
class Processor extends Actor {
def receive: Receive = {
case msg: String => doProcess(msg)
case _ =>
}
}
Where is this class defined? It is not imported into this class. How the system will find the Receive class
+3
source to share
3 answers
It is an alias for a type PartialFunction[Any, Unit]
defined within a akka.actor.Actor
companion object and its properties, respectively.
Excerpt from source code :
object Actor {
// Type alias representing a Receive-expression for Akka Actors.
type Receive = PartialFunction[Any, Unit]
// ...
}
trait Actor {
// to make type Receive known in subclasses without import
type Receive = Actor.Receive
// ...
}
+6
source to share