I have the following classes
case class A(vl: Int)
case class B(name: String)
now I want to create a class like this
case class Cllction[T](objs: Seq[T])
But the thing is I want to restrict to be only either A
or B
. Is it possible to do so in Scala? I mean for example if I try to create like this:
val s = Seq[Int]()
val c = Cllction(s) // should be compile error
Is it possible to do?