Created
March 13, 2013 21:50
-
-
Save stephenh/5156672 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object foo { | |
var comparisons = 0 //> comparisons : Int = 0 | |
class Foo { | |
override def equals(other: Any) = { comparisons += 1; super.equals(other) } | |
} | |
class Bar extends Foo | |
class Baz extends Foo | |
val s1: Set[Foo] = Seq.fill(10)(new Bar).toSet //> s1 : Set[foo.Foo] = Set(foo$$anonfun$main$1$Bar$1@1529d183, foo$$anonfun$ma | |
//| in$1$Bar$1@7d1f0c98, foo$$anonfun$main$1$Bar$1@1740f55, foo$$anonfun$main$1$ | |
//| Bar$1@c8a3c71, foo$$anonfun$main$1$Bar$1@6a9a9631, foo$$anonfun$main$1$Bar$1 | |
//| @2009d3af, foo$$anonfun$main$1$Bar$1@47862525, foo$$anonfun$main$1$Bar$1@548 | |
//| ccbe7, foo$$anonfun$main$1$Bar$1@37f0c4d2, foo$$anonfun$main$1$Bar$1@4afaa1a | |
//| 4) | |
println(comparisons) //> 20 | |
comparisons = 0 | |
s1 contains (new Baz) //> res0: Boolean = false | |
println(comparisons) //> 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment