Kenneth
03/11/2019, 12:14 PMval nodeId: UUID = UUID.randomUUID()
inside a data class generate a new uuid each time I make a new instance of the class?diesieben07
03/11/2019, 12:14 PMKenneth
03/11/2019, 1:37 PMKenneth
03/11/2019, 1:37 PMKenneth
03/11/2019, 1:38 PMSiebelsTim
03/11/2019, 3:09 PMStevieB
03/11/2019, 3:23 PMStevieB
03/11/2019, 3:29 PMval groups = people.chunked(2).map { Group(it) }
ilya.gorbunov
03/11/2019, 4:26 PMchunked
function docs (https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/chunked.html):
... the list passed to the transform function is ephemeral and is valid only inside that function. You should not store it or allow it to escape in some way, unless you made a snapshot of it.So use the version with
map
proposed by @StevieB or make a snapshot of each group list with the extension `toList()`:
chunked(2) { Group(it.toList()) }