package sample object Sample { def main(args: Array[String]): Unit = { val a = List(1,2,3) val b = List(4,5,6) println(a :: b) println(a ::: b) } }
List(List(1, 2, 3), 4, 5, 6) List(1, 2, 3, 4, 5, 6)
JavaでいうList#add()とList#addAll()だね。
package sample object Sample { def main(args: Array[String]): Unit = { val a = List(1,2,3) val b = List(4,5,6) println(a :: b) println(a ::: b) } }
List(List(1, 2, 3), 4, 5, 6) List(1, 2, 3, 4, 5, 6)
JavaでいうList#add()とList#addAll()だね。