I have a list of objects of class AA that contain a date and a list of objects of class BB:
data class AA(
val date: LocalDate,
val bb: List<BB>
)
@Parcelize
data class BB(
val x: Int,
val y: String,
val z: String
) : Parcelable
I want to create a single List (flatten List<AA>
) that will look like this:
listOf(
date obj
BB obj
BB obj
date obj
BB obj
date obj
BB obj
BB obj
BB obj)
Instead of:
listOf(
date obj, listOf(BB obj, BB obj)
date obj, listOf(BB obj)
date obj, listOf(BB obj, BB obj, BB obj))
I tried using flatMap, but I only manage to flatten one part - BB.
How to crate a list with date and BB items?
item
in the flattened list? It does not seem to appear in theList<AA>
– Rafaelrafaela