Prepend to String array

Viewed 3653

I want to prepend an element to an array. I assumed I should use :+ but it seems this does not work:

scala> val nodes: Array[String] = Array("b", "c")
nodes: Array[String] = Array(b, c)

scala> val updatedNodes = "a" :+ nodes
updatedNodes: scala.collection.immutable.IndexedSeq[Any] = Vector(a, Array(b, c))

How should I prepend "a" to give Array("a", "b", "c")

2 Answers
Related