Your data class should have mutable properties so that they can be changed:
fun <T> updateWorkerData(id: Int, property: KMutableProperty1<Worker, T>, value: T) { val workers = getListOfWorker() workers.forEach { if (it.id == id) { property.set(it, value) } } } updateWorkerData(1, Worker::age, 28)
No comments:
Post a Comment