I have a list of object PersonInfo, if certain fields in the PersonInfo object are same with another PersonInfo object, i'll say these two objects are duplicated. example:
case class PersonInfo(
firstName: Instant,
lastName: Instant,
ssn: String,
email: String
)
if two PersonInfo objects have same 'ssn', they are duplicated record. my list looks like this:
val list = List(pi1, pi2, pi3)
pi1 is: PersonInfo("foo", "foo", "123-456-789", "[email protected]")
pi2 is: PersonInfo("bar", "bar", "456-123-789", "[email protected]")
pi3 is: PersonInfo("gee", "gee", "123-456-789", "[email protected])
how can i filter the list to only return list of (pi1 and pi3) since pi1 and pi3 are duplicated:
list.filter(f => pi1.ssn == pi3.ssn) => ???
and I expect it to return List(pi1, pi2)
equalsmethod on your case class and usedistinct.only return list of (pi1 and pi3)conflicts withexpect it to return List(pi1, pi2)