Say I have an Array[Int] like
Array[Int]
val array = Array( 1, 2, 3 )
Now I would like to append an element to the array, say the value
val array2 = array :+ 4 //Array(1, 2, 3, 4)
Works also "reversed":
val array2 = 4 +: array Array(4, 1, 2, 3)
There is also an "in-place" version:
var array = Array( 1, 2, 3 ) array +:= 4 //Array(4, 1, 2, 3) array :+= 0 //Array(4, 1, 2, 3, 0)