Hey,
For this purpose, we use the single value ‘:+’.
scala> var a=List.empty[String]
a: List[String] = List()
scala> a :+="red"
scala> a :+="green"
scala> a :+="blue"
scala> a
The output will be:
List[String] = List(red, green, blue)
Now to append a list to it:
scala> a++=List("golden","bronze")
scala> a
The output will be:
List[String] = List(red, green, blue, golden, bronze)
Hope this helps!!
If you need to learn more about Scala, It's recommended to join Scala Certification course today.
Thank you!