Skip to content

Instantly share code, notes, and snippets.

@krisajenkins
Last active December 29, 2015 08:08
Show Gist options
  • Save krisajenkins/7640872 to your computer and use it in GitHub Desktop.
Save krisajenkins/7640872 to your computer and use it in GitHub Desktop.
Erm...WAT.
class Thing {
var x = 5
override def equals(o: Any) = o match {
case that: Thing => that.x == this.x
case _ => false
}
}
val a = new Thing
val b = new Thing
val stuff = scala.collection.immutable.Set(a, b)
println(stuff.size) // Prints 1.
println(a equals b) // Prints true
b.x = 10
println(stuff.size) // Still 1
println(a equals b) // Now false.
println(a.x, b.x) // Prints (5,10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment