3

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

Community
  • 1
  • 1
Alex
  • 592
  • 4
  • 10
  • Since object does not have a constructor it cannot be done. But you can have a class extending the other class `class B(implicit imp: Int) extends A(imp)` – Eugene Ryzhikov Mar 17 '14 at 21:05

2 Answers2

5

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
Daniel C. Sobral
  • 295,120
  • 86
  • 501
  • 681
1
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> 
nairbv
  • 4,045
  • 1
  • 24
  • 26