Skip to content

Instantly share code, notes, and snippets.

@yuroyoro
Created May 25, 2010 07:53
Show Gist options
  • Save yuroyoro/412897 to your computer and use it in GitHub Desktop.
Save yuroyoro/412897 to your computer and use it in GitHub Desktop.
// immutable.TreeSetで + で要素を追加されるとSort順がヘンなTreeSetが返る。これバグなの?
scala> val l = List( "bbb","aa" ,"eee","cc")
l: List[java.lang.String] = List(bbb, aa, eee, cc)
scala> val ts = TreeSet( l : _* )
ts: scala.collection.immutable.TreeSet[java.lang.String] = TreeSet(aa, bbb, cc, eee)
scala> val newts = ts + "ab"
newts: scala.collection.immutable.TreeSet[java.lang.String] = TreeSet(eee, ab, bbb, cc, aa)
scala> newts + "ca"
res43: scala.collection.immutable.TreeSet[java.lang.String] = TreeSet(eee, ca, ab, bbb, cc, aa)
scala> newts + "a"
res44: scala.collection.immutable.TreeSet[java.lang.String] = TreeSet(eee, a, ab, bbb, cc, aa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment