How to declare traits as taking implicit “constructor parameters”?

后端 未结 5 2014
孤街浪徒
孤街浪徒 2020-12-23 16:45

I\'m designing a class hierarchy, which consists of a base class along with several traits. The base class provides default implementations of several methods, and the trai

5条回答
  •  时光说笑
    2020-12-23 17:07

    As it looks like this isn't possible, I went for the option of declaring the implicit val on the base class' constructor. As pointed out in the question this isn't ideal, but it satisfies the compiler and, pragmatically, isn't too much of a burden in my particular case.

    If anyone has a better solution though, I'd be happy to hear and accept it.

提交回复
热议问题