Vivek Modi
06/15/2022, 3:18 PMfun getConsultationCoverageList(): List<ContentWithTitle> {
    val list = mutableListOf<ContentWithTitle>()
    val consultation = getConsultationItem()
    consultation?.consultationCategories?.forEachIndexed { _, consultationCategory ->
        val paragraphs = mutableListOf<Paragraph>()
        consultationCategory.consultationTopics?.forEachIndexed { _, consultationTopics ->
            paragraphs.add(Paragraph(type = LIST_ITEM.type, text = consultationTopics.title))
        }
        list.add(ContentWithTitle(title = consultationCategory.title, content = Paragraphs(paragraphs), description = consultationCategory.description))
    }
    return list
}Joffrey
06/15/2022, 3:19 PMforEachIndexed { _, x -> ... }forEachJoffrey
06/15/2022, 3:21 PMparagraphs = mutableListOf()forEach { paragraphs.add(something) }map {}val paragraphs = consultationCategory.consultationTopics.orEmpty().map {
    Paragraph(type = LIST_ITEM.type, text = it.title)
}.orEmpty()Joffrey
06/15/2022, 3:22 PMval list = mutableListOfforEach { list.add(..) }ephemient
06/15/2022, 3:22 PMgetConsultationItem()?.consultationCategories?.map { category ->
    val paragraphs = category.consultationTopics?.map {
        Paragraph(...)
    }.orEmpty()
    ContentWithTitle(...)
}.orEmpty()Vivek Modi
06/15/2022, 3:27 PMVivek Modi
06/15/2022, 3:29 PM2 foreachn^2mapJoffrey
06/15/2022, 3:30 PMmapJoffrey
06/15/2022, 3:32 PMmapVivek Modi
06/15/2022, 3:33 PMJoffrey
06/15/2022, 3:34 PMval paragraphs = consultationCategory.consultationTopics.orEmpty().map {
    Paragraph(type = LIST_ITEM.type, text = it.title)
}val paragraphs = consultationCategory.consultationTopics.orEmpty().map { it.toParagraph() }private fun ConsultationTopic.toParagraph() = Paragraph(type = LIST_ITEM.type, text = title)Vivek Modi
06/15/2022, 3:38 PMephemient
06/15/2022, 3:42 PMJoffrey
06/15/2022, 3:44 PMfun getConsultationCoverageList(): List<ContentWithTitle> =
    getConsultationItem()?.consultationCategories.orEmpty().map { it.toContentWithTitle() }
private fun ConsultationCategory.toContentWithTitle(): ContentWithTitle =
    ContentWithTitle(title = title, content = paragraphs, description = description)
private val ConsultationCategory.paragraphs
    get() = Paragraphs(consultationTopics.orEmpty().map { it.toParagraph() })
private fun ConsultationTopic.toParagraph() = Paragraph(type = LIST_ITEM.type, text = title)Vivek Modi
06/15/2022, 3:49 PMVivek Modi
06/15/2022, 3:50 PMJoffrey
06/15/2022, 3:53 PMnull.orEmpty()Vivek Modi
06/15/2022, 3:54 PM.orEmpty()Joffrey
06/15/2022, 3:55 PM?.Vivek Modi
06/15/2022, 3:56 PM