I have a JSON protocol written in spray
trait MyJsonProtocol {
//some logic
}
object MyJsonProtocol extends MyJsonProtocol {
}
Now which i
It depends on the scenario, Because a companion class or object can access the private members of its companion. Use a companion object for methods and values which are not specific to instances of the companion class. If you just want multiple inheritance but allow code reusability then trait is fine.
Hope it helps.