Reputation: 1807
I have a list of a custom date type:
val dates = mutableListOf(
Date(year = 2020, month = 4, day = 3),
Date(year = 2021, month = 5, day = 16),
Date(year = 2020, month = 1, day = 29)
)
And a set of "months" I need to ensure are in the list:
val months = listOf(1, 4)
Is there a way to check if dates
contains all of the months
from the list? I feel like there could be a way to do this using the .containsAll()
function on the initial list, but I am not sure.
Upvotes: 1
Views: 60
Reputation: 560
Does this solve your problem?
dates.map { it.month }.containsAll(months)
Upvotes: 2