Scala union example

The scala union function is very simple – it takes one sequence on the end of another:

List(1, 2, 3).union(List(2, 3, 4))

res33: List[Int] = List(1, 2, 3, 2, 3, 4)

Note however that this function is probably a poor naming choice – in both set theory and SQL, a “union” implies that you have computed a unique list of two lists of values.

Leave a Reply

Your email address will not be published. Required fields are marked *