I have a function that expects two arguments from type Set
:
def union[A](set1: Set[A], set2: Set[A]): Set[A] = {
set1.foldLeft(set2){ (set, elt) => (set + elt) }
}
Apply function as follow:
union(Set(3,4,5,6), Set(34,56,23))
and I've got:
res2: Set[Int] = Set(5, 56, 6, 34, 3, 23, 4)
but I expect:
Set(3,4,5,6,34,56,23)
Why do I receive such as unordered result?