Pablo
05/27/2021, 8:13 AMdata class Foo (val id: String, val name: String)
val fooList = listof<Foo>(Foo("1","foo1"),Foo("2","foo22)
Imagine I get this fooList
as a parameter and I want to update this list, do I need to do a clone
of the list and then a copy
of the data class
and update there the values?gildor
05/27/2021, 8:17 AMPablo
05/27/2021, 8:21 AMgildor
05/27/2021, 8:22 AMgildor
05/27/2021, 8:24 AMgildor
05/27/2021, 8:25 AMfun doSomething(list: List<Foo>) {
val newList = list.map { foo ->
foo.copy(name = foo.name.uppercase() )
}
println(newList)
}
a_wer1986
05/27/2021, 9:01 AMval list = listOf<Any>()
val mutList = list.toMutableList()
// TODO: apply changes to mutList, e.g. add or remove items
val result = mutList.toList()
Pablo
05/31/2021, 1:53 PMPablo
05/31/2021, 1:56 PMval list = List<Foo>
val foundValue = list.find{it.title == "foo1"}
Here I need to change the value of that value
gildor
06/01/2021, 6:25 AMgildor
06/01/2021, 6:25 AMgildor
06/01/2021, 6:25 AM