且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Scala:将元素附加到数组的***方法是什么?

更新时间:2023-11-28 22:38:34

您可以使用 :+ 将元素附加到数组,并使用 +: 附加它:>

You can use :+ to append element to array and +: to prepend it:

0 +: array :+ 4

应该产生:

res3: Array[Int] = Array(0, 1, 2, 3, 4)

它与 Seq 的任何其他实现相同.

It's the same as with any other implementation of Seq.