Since lists in scala are covariant, you can add any object to the list as long as it is a subtype of the type of the list.
class GenericTest[C](a: IndexedSeq[C], b: IndexedSeq[C]) {
def run: IndexedSeq[C] = {
// special case #1: need to return empty sequence here
if (a.size == 0) {
return IndexedSeq.empty[C]
}
// special case #2: need to return original input here
if (a == b) {
return a
}
val result = mutable.ArrayBuffer[C]()
for (i <- 0 until scala.math.min(a.size, b.size)) {
result += a(i)
result += b(i)
}
result.toIndexedSeq
}
}