For example, I have
trait Logger {
def log(m: Message) = ???
}
If I want to pass a Logger
as parameter I would simple call def foo(l: Logger)
.
But if I have
trait Logger {
def log(m: Message) = ???
def receive = {
case m: Message = log(m)
}
}
,I must pass an ActorRef
to be able to call !
/?
etc on it. But that completely breaks type safety - def log(ar: ActorRef)
, and nothing says that it should be an Logger
underneath.
So, in the end I'd like to call
class Foo(logger: Logger) {
def foo(m: Message) = logger ! message
}