Reuse a case class inside an object in scala -


i have object contains 1 or more case classes , associated methods. reuse case class within object (which has similar characteristics object differentiating methods).

private object abc {     /* ... */      case class xyz(..) { def somefunc(){} }      object xyz { def apply() {} } }  private object extendabc {      // how reuse case class xyz here? } 

if want access can use kind of code .

private object abc {  case class xyz() {  def somefunc(){}  }  object xyz {  }  }  private object extendabc { val = new abc.xyz() a.somefunc() } 

you need call way because xyz nested member of object abc . here.

also please note cannot define apply method in companion object of case class provides exact same apply() method (with same signature.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -