elect
09/15/2023, 4:39 PMval unsInfos = intTypeInfo.filter { it.type[0] == 'U' }
val signInfos = intTypeInfo.filter { it.type[0] != 'U' }
ie
val (unsInfos, signInfos) = intTypeInfo.x { it.type[0] == 'U' }
elect
09/15/2023, 4:42 PMpartition
!Russell Stewart
09/15/2023, 4:42 PMelect
09/15/2023, 4:43 PMsplit
or divide
, then by defining the type, at the end I managed to find the answer on GoogleRussell Stewart
09/15/2023, 4:44 PMelect
09/15/2023, 4:45 PMDestructuring declarations are only allowed for local variables/values😕
Russell Stewart
09/15/2023, 4:47 PMtype
in the scope where you're filtering/partitioning? Is type
a sub-array in the object?elect
09/15/2023, 4:48 PMval intTypeInfo = listOf(
TypeInfo("Byte", "b"),
where
data class TypeInfo(val type: String, val extension: String)
elect
09/15/2023, 4:49 PMRussell Stewart
09/15/2023, 4:49 PMRussell Stewart
09/15/2023, 4:52 PMintTypeInfo
?elect
09/15/2023, 4:52 PMval (unsInfos, signInfos)
at top levelRussell Stewart
09/15/2023, 4:52 PMelect
09/15/2023, 4:52 PMRussell Stewart
09/15/2023, 4:52 PMRussell Stewart
09/15/2023, 4:53 PMunsInfo
and signInfos
as vals at the top level, then do your partition
call in the init
block.elect
09/15/2023, 4:54 PMinit
Russell Stewart
09/15/2023, 4:54 PMRussell Stewart
09/15/2023, 4:54 PMList<TypeInfo>
?elect
09/15/2023, 4:55 PMRussell Stewart
09/15/2023, 4:57 PMKlitos Kyriacou
09/15/2023, 5:03 PMprivate val pair = ...partition(...)
val unsInfos = pair.first
val signInfos = pair.second
ephemient
09/15/2023, 5:24 PM