How to compare two objects for equality in Scala?
问题 I have a very basic equality check between two objects but it fails. package foo import org.junit.Assert._ object Sandbox extends App{ class A val a = new A val b = new A assertEquals(a, b) } My use-case is more complex but I wanted to get my basics right. I get an assertion error when I run the code: Caused by: java.lang.AssertionError: expected:<foo.Sandbox$A@3f86d38b> but was:<foo.Sandbox$A@206d63fd> at org.junit.Assert.fail(Assert.java:88) at org.junit.Assert.failNotEquals(Assert.java:743