i have a simple PartialFunction
type ChildMatch = PartialFunction[Option[ActorRef], Unit]
def idMatch(msg: AnyRef, fail: AnyRef)(implicit ctx: ActorContext): ChildMatch = {
case Some(ref) => ref forward msg
case _ => ctx.sender() ! fail
}
but when i tried to use this - compiler wants a declaration like this:
...
implicit val ctx: ActorContext
val id: String = msg.id
idMatch(msg, fail)(ctx)(ctx.child(id))
as you can see it wants ctx as second parameter not implicitly
how i can change my idMatch function to use it like this:
...
implicit val ctx: ActorContext
val id: String = msg.id
idMatch(msg, fail)(ctx.child(id))
?
The compiler will always assume that the second argument list stands for the implicit argument list. You have to split the invocations of the two functions in some way. Here are some possibilities:
idMatch(msg, fail).apply(ctx.child(id))
val matcher = idMatch(msg, fail)
matcher(ctx.child(id))
// Provides the implicit explicitly from the implicit scope
idMatch(msg, fail)(implicitly)(ctx.child(id))