Merging Lists

An example to merge 2 Lists
scala> // o990 -> a15

scala> val list1 = List('a','b', 'c')
list1: List[Char] = List(a, b, c)

scala> val list2 = List('d', 'e', 'f')
list2: List[Char] = List(d, e, f)

scala> // Using :::

scala> val res1 = list1 ::: list2
res1: List[Char] = List(a, b, c, d, e, f)

scala> // Using ++

scala> val res2 = list1 ++ list2
res2: List[Char] = List(a, b, c, d, e, f)

scala> // Using concat()

scala> val res3 = List.concat(list1, list2)
res3: List[Char] = List(a, b, c, d, e, f)

No comments:

Post a Comment