The short answer is no. The Scala compiler will only look to apply one implicit, so if it does not detect an implicit int lying around, it will stop and give up.
However, you can write your purchaseCandles method to work with types that can be converted to Int , and require a parameter of this type:
def purchaseCandles[A <% Int]()(implicit age : A) = { val asAge : Int = age println(s"I'm going to buy $asAge candles!") }
The asAge part asAge necessary to enforce implicit conversion.
At present, it seems to me that I need to specify type A in this scenario, although I cannot understand why: since there should not be other values โโaround types that can be implicitly converted to Int (this happens with completely new types, therefore this is not the ubiquity of Int .) But you can do:
{ implicit val guest = Monkey(10000) purchaseCandles[Monkey]() }
This use of implicits, however, is probably bad ideas!
source share