arve
02/12/2019, 10:04 AMfun getFilm(title: String): Film {
val data = db.getFilm(title)
return data.copy(actors = data.actors.filterNot { it.isDead) })
}
Is there a way to avoid the temp variable without hitting the db twice? Or put differently, is there a way of referencing the source object in a copy operation somehow?
Ideally I'm looking for something like fun getFilm(t: String) = db.getFilm(t).copy(actors = actors.filterNot { it.isDead })
I'm aware of with
, but in cases like this, with
feels even more convoluted.Tom Adam
02/12/2019, 4:13 PM