Scala basics-List
statementvar list = List(1,2,3,4) println(list)Empty listvar foo = List() println(foo) var bar = Nil println(bar)::The :: (two colons) operator is right-associative. If you want to build a list List(1,2,3,4), you can actually use the following method, Nil means an empty list.scala> 1::2::3::4::Nil res6: List[Int] = List(1, 2, 3, 4)A list has the concept of a head and a tail. It headreturns the first element of the list and tailreturns a list, except 第一元素之外的其他元素that the head is an element, and
watch_later Read article