https://kotlinlang.org logo
#getting-started
Title
# getting-started
m

Midoriya

09/19/2022, 4:45 AM
i have list of TodoItem
Copy code
data class TodoItem(
    val taskName :String,
    val isCompleted : Boolean  = false,
)

 private val taskList = mutableListOf<TodoItem>()
how can i change an element 'isCompleted' to true. so if user said 4th element is completed how can i change it to complete
Copy code
taskList[index] = TodoItem(taskName = taskList[index].taskName, isCompleted = true)
like this???
e

ephemient

09/19/2022, 4:46 AM
Copy code
taskList[index] = taskList[index].copy(isCompleted = true)
m

Midoriya

09/19/2022, 4:50 AM
thankyou 😄
9 Views