Is there a method to purge (clean to default values) of a data class instead of recreating it? Like
val cache = Cache()
cache.purge()
data class Cache(
val list1: MutableList<Int> = mutableListOf()
val list2: MutableList<Int> = mutableListOf()
)
It’s a minor case and there can be troubles with non-default values but maybe it can be useful. Other way is to make a nested class like:
class CachePurgeable{
var cache = Cache()
private set
fun purge() {
cache = Cache()
}
}