scala list append code example
Example 1: scala list append to end
Append to end of list
List(1,2,3) :+ 4
Results in List[Int] = List(1, 2, 3, 4)
Example 2: scala add to list
def::[B >: A](elem: B): List[B]
Adds an element at the beginning of this list.
elem is the element to prepend.
returns a list which contains x as first element
and which continues with this list.
Example:
1 :: List(2, 3) = List(2, 3).::(1) = List(1, 2, 3)