I have a mutable map
val weeklyCheck = mutableMapOf(
Day.MONDAY to true,
Day.TUESDAY to true,
Day.WEDNESDAY to true,
Day.THURSDAY to true,
Day.FRIDAY to true,
Day.SATURDAY to true,
Day.SUNDAY to true
)
How do I set all the keys to false. Currently I am using something like this, is there a better way to do this.
private fun resetDays() {
weeklyCheck.put(Days.MONDAY, false)
weeklyCheck.put(Days.TUESDAY, false)
weeklyCheck.put(Days.WEDNESDAY, false)
weeklyCheck.put(Days.THURDSAY, false)
weeklyCheck.put(Days.FRIDAY, false)
weeklyCheck.put(Days.SATURDAY, false)
weeklyCheck.put(Days.SUNDAY, false)
}
You can use
replaceAll
- ignore the given key and value, and just returnfalse
no matter what. This will replace everything withfalse
.