Created
February 19, 2016 10:49
-
-
Save gigiigig/45f0e8f5d3322f03b085 to your computer and use it in GitHub Desktop.
Inheritance brake class eqaulity
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
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