Combining Arrays in Scala

后端 未结 1 1151
无人及你
无人及你 2021-01-07 20:30

If I have DerivedType1:BaseType and DerivedType2:BaseType and Array[DerivedType1] and Array[DerivedType2], what\'s the mo

相关标签:
1条回答
  • 2021-01-07 21:01

    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)
    
    0 讨论(0)
提交回复
热议问题