Skip to content

Instantly share code, notes, and snippets.

@davidandrzej
Created December 9, 2012 18:25
Show Gist options
  • Save davidandrzej/4246368 to your computer and use it in GitHub Desktop.
Save davidandrzej/4246368 to your computer and use it in GitHub Desktop.
Scala Seq.union behavior - come on!
scala> val x = Seq(1,2)
x: Seq[Int] = List(1, 2)
scala> val y = Seq(2,3)
y: Seq[Int] = List(2, 3)
scala> x.union(y)
res0: Seq[Int] = List(1, 2, 2, 3)
@davidandrzej
Copy link
Author

Yeah IMO union is pretty suggestive naming for this method which would lead me to believe it had Set.union semantics. The Scala collection docs finesse this by saying Seq.union is multiset-union, but I guess it would surprise me especially if IntelliJ autocomplete helped me call union on a datatype which I didn't explicitly realize to be Seq...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment