I'm learning Kotlin and Spring and was developing mini project for learning experience. This function is for updating todo's which are already created/added and find it by Id and update the data. But I get Unresolved Reference: copy, and no documentation found.
fun putTodo(id: Long, newTodo: Todo): ResponseEntity<Todo> = todoRepository.findById(id).map { currentTodo -> val updatedTodo: Todo = currentTodo.copy( title = newTodo.title, status = newTodo.status ) ResponseEntity.ok().body(todoRepository.save(updatedTodo)) }.orElse(ReponseEntity.notFound().build())