Hi. I have a data class with three properties: `My...
# getting-started
a
Hi. I have a data class with three properties:
MyClass(groupId, datetime, someValue)
Next, I have a
Set<MyClass>
, which can contain multiple entries with the same groupId. I want to turn this into a
Set<MyClass>
that contains the latest(by datetime) entry for each groupId. What’s a good functional/stream-like way of achieving this?
a
arve: something like
Set<MyClass>.groupBy { it.datetime }.map { it.value[0] }