Question

class B(implicit imp: Int) extends AC { }

object C extends B{

}

Error: could not find implicit value for parameter imp

This is what i was looking for: How to provide default value for implicit parameters at class level

Was it helpful?

Solution 2

scala> class B(implicit imp:Int)
defined class B

scala> class C extends B()(1)
defined class C

scala> implicit val imp:Int = 2
imp: Int = 2

scala> class D extends B
defined class D

scala> 

OTHER TIPS

You extend it like you extend a class with non-implicit parameters, but you need an empty parameter list first:

scala> object C extends B()(5) {}
defined module C
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top