The Actor DSL example from Akka doc

akka, scala

Solution

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 {
  ...
}

Problem

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: akka.actor.ActorDSL.Inbox)akka.actor.ActorRef and value self in trait Actor of type => akka.actor.ActorRef match expected type akka.actor.ActorRef below is my code, ``` import akka.actor.ActorDSL._ import akka.actor.ActorSystem import scala.concurrent.duration._ implicit val system: ActorSystem = ActorSystem("demo") implicit val i = inbox() val a = actor(new Act { become { case "hello" ⇒ sender ! "hi" } }) a ! "hello" val reply = i.receive() ``` here I can't use "!" to send message, only can use "tell" like sender.tell("hi", null), does anybody know how to fix this issue?

Original source