I try to implement Actor DSL example from akk doc, but found error,
ambiguous implicit values: both method senderFromInbox in trait Inbox of type (implicit inbox
Short answer (only for REPL without :paste
mode):
val a = ...
implicit val i = inbox()
You should pass self
, not null
as second parameter (sender
) of tell
method. Method !
takes this parameter implicitly and invokes tell
. There are 2 implicit ActorRef
in scope of sender ! "hi"
: i
and self
(field of Act
) - compiler can't figure out which one you need.
You should remove implicit val i
from scope of sender ! "hi"
.
Correct solution - move actor creation to method and all other code - to other method. In REPL you could create a
before i
.
Quick dirty solution - hide i
like this:
val a = {
val i = 0
actor(new Act {
...
}