Extracting a list of values from a list of case classes


I have a List[Date] that uses a case class Date(day: Int, month: Int, year: Int).
How could I potentially transform this into a distinct List[Int] full of day Ints.

I’ve tried days = dateList.groupBy (date => date.day) but then I’m not too sure where to go from there. I also know of the distinct method but don’t know how I can make a list of distinct days and not distinct Dates.

here’s a possible solution.

val ls: List[Date] = List(Date(1, 2, 2021), Date(1, 3, 2021))

How about:

Example code in Scala 3: