Skip to content

Instantly share code, notes, and snippets.

@gigiigig
Created February 19, 2016 10:49
Show Gist options
  • Save gigiigig/45f0e8f5d3322f03b085 to your computer and use it in GitHub Desktop.
Save gigiigig/45f0e8f5d3322f03b085 to your computer and use it in GitHub Desktop.
Inheritance brake class eqaulity
trait Foo {
case class Bar(i: Int, s: String)
}
val fb1 = new Foo {}.Bar(3, "ciao")
val fb2 = new Foo {}.Bar(3, "ciao")
val equal = fb1 == fb2
println(s"equal: ${equal}") // equal: false
case class ReBar(i: Int, s: String)
val rb1 = ReBar(1, "ciao")
val rb2 = ReBar(1, "ciao")
val reequal = rb1 == rb2
println(s"reequal: ${reequal}") // reequal = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment