I have a list of Person
objects. Each Person
object has an int id
property, along with some others. Currently my list of Person
objects has multiple objects with the same id
. I want to filter the list so each id
only exists at most once in the list.
E.g. a list of
Person(1),
Person(1),
Person(2),
Person(2),
Person(3),
Person(1)
should look like
Person(1),
Person(2),
Person(3)
In ruby this is simply personList.uniq { |person| person.id }