Marcin Wisniowski
04/04/2023, 9:47 PMlist.groupBy { it.property }.map { (_, list) -> list.first() }
Is there a simpler way? This is something I would normally solve with .toSet()
, except I only want to consider one property of the data class, not the entire item.molikuner
04/04/2023, 10:05 PMlist.distinctBy { it.property }
ephemient
04/04/2023, 11:23 PMlist.filter(mutableSetOf<Any?>()::add)
but it's nice to have it as its own function :)Marcin Wisniowski
04/05/2023, 6:22 PMdistinctBy
is exactly what I was hoping for thanks!