Ways to create a Sequence

Seq is the parent type of all Concrete collections(List, Vector etc...) that support Iteration. Nil represents an Empty List
scala> val seq1 = Seq(1, 2)
//PS:104, 107
seq1: Seq[Int] = List(1, 2)

scala> val seq2 = (1 +: (2 +: (Nil)))
seq2: List[Int] = List(1, 2)

scala> val seq3 = (1 :: (2 :: (Nil)))
seq3: List[Int] = List(1, 2)

No comments:

Post a Comment