Skip to content

Instantly share code, notes, and snippets.

@fommil
Last active January 17, 2017 07:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fommil/b4586521a1578f8bf272cd7b68f24003 to your computer and use it in GitHub Desktop.
Save fommil/b4586521a1578f8bf272cd7b68f24003 to your computer and use it in GitHub Desktop.
puzzler
import scala.collection.immutable._
case class Foo(s: String)
// what do you expect?
implicit val ordering = Ordering[String]
val tree = TreeMap.empty ++ (1 to 100).map { i => Foo(i.toString) -> i }
tree.getClass
// compared to
implicit val ordering = new Ordering[Foo] { def compare(a: Foo, b: Foo): Int = 0 }
val tree = TreeMap.empty ++ (1 to 100).map { i => Foo(i.toString) -> i }
tree.getClass
@SethTisue
Copy link

SethTisue commented Dec 3, 2016

I'd like this a little better as "what is the type of tree" instead of "what does getClass say" since it's really a types problem not a runtime problem

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