mercredi 29 septembre 2021

Scala Case Class Inheritance for common vals

I am having case class that has few vals which are used only for 1 conditions.

case class ExampleCase(name:String, age:Int , abc:Int , abc1:Int )

Here abc is used or assigned only for 1 scenario and for other scenario we use only abc1

Wanted to create a trait so that we have mandatory vals in trait and then extend that trait with 2 case class and 1 having abc and one more having abc1.

Please suggest me best approach for this.

Aucun commentaire:

Enregistrer un commentaire