Reputation: 6583
If I have DerivedType1:BaseType
and DerivedType2:BaseType
and Array[DerivedType1]
and Array[DerivedType2]
, what's the most succinct way of combining them into Array[BaseType]
?
Upvotes: 24
Views: 25822
Reputation: 92046
Use the ++
method on Array
.
scala> class A; class B extends A; class C extends A
defined class A
defined class B
defined class C
scala> Array(new B, new B) ++ Array(new C, new C)
res33: Array[A] = Array(B@b7501b, B@ec5359, C@1540d0c, C@124a927)
Upvotes: 39