Adam Cooper
10/28/2022, 4:12 PMval wordle = Wordle()
get() {
if (this.lastWordListRefresh + 1.hours < Clock.System.now()) {
return Wordle().also {
<http://this.log.info|this.log.info>("Refreshing Wordle state")
this.lastWordListRefresh = Clock.System.now()
}
}
return field
}
My understanding was that returning a different value from get
would set the backing field. But it seems that, if lastWordListRefresh
has "expired", it returns a new object once, and then continues using the old backing object for subsequent calls. Is there a way to make it so that the value returned from get
sets the backing field? I essentially want a property that expires, and then lazily refreshes itself.David Perez
10/28/2022, 4:33 PMDavid Perez
10/28/2022, 4:33 PMval wordle = Wordle()
get() {
if (this.lastWordListRefresh + 1.hours < Clock.System.now()) {
field = Wordle().also {
<http://this.log.info|this.log.info>("Refreshing Wordle state")
this.lastWordListRefresh = Clock.System.now()
}
}
return field
}
Adam Cooper
10/28/2022, 4:36 PMvar
in order to do that. If I don't define the setter, does that mean it can't be updated externally?David Perez
10/28/2022, 4:40 PMDavid Perez
10/28/2022, 4:41 PMvar wordle = Wordle()
get() {
if (this.lastWordListRefresh + 1.hours < Clock.System.now()) {
field = Wordle().also {
<http://this.log.info|this.log.info>("Refreshing Wordle state")
this.lastWordListRefresh = Clock.System.now()
}
}
return field
}
private set
Adam Cooper
10/28/2022, 4:43 PMDavid Perez
10/28/2022, 4:44 PM