``` list.map { arrayOf(it.rfid.rfid, it.pr...
# announcements
x
Copy code
list.map { arrayOf(it.rfid.rfid, it.pressureSignal, it.uoPressure, it.chamberPressure, it.ultrasonicSignal, it.rfid.timestamp) }
given this map, I want to flatten the whole list into one big array (no nested arrays), but I’m not sure how to take each element of this array and map it to just an element
d
flatMap
?
x
but flatmap what?
d
Same as in Java? 😄
Or really you can just use
flatMap
in place of
map
in this case
x
I don’t have a stream here though?
d
Kotlin's List already has flatMap
No need for a stream.
s
right, you don’t need an intermediate stream
I feel like there’s something about the shape of your list I don’t understand, given your question
x
it’s just a list of objects, and I want to take the properties and map it into one big list
d
Yeah. That's what
flatMap
does.
x
I feel like I’m missing some obvious to not me syntax with flatmap
Copy code
list.flatMap {
            it.rfid.rfid,
            it.pressureSignal,
            it.uoPressure,
            it.chamberPressure,
            it.ultrasonicSignal,
            it.rfid.timestamp
         }
that obviously won’t work
d
You have to return a list.
x
ah
so return listOf instead of arrayOf?
s
yep
x
ok, that’s what I was missing, I knew it was something dumb…