Last active
March 3, 2022 18:09
-
-
Save EmmanuelGuther/ae891e868bcee4dbc3cc340b0513f10a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val selectedSubcategories = selectedCategories.asSequence().map { it?.subCategories }.fold(mutableSetOf<SubCategoryModel>()) { acc, list -> | |
list?.asSequence()?.filter { it.checked }?.map { acc.add(it) }?.toList() | |
acc | |
} | |
val subcategoriesJoined = selectedSubcategories.asSequence().map { it.name }.joinToString(separator = " • ") | |
editTextProfessionalRegisterCategories.setText(subcategoriesJoined) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have this list and you want all the names from within the sublists.
[ { "checked": false, "name": "Alpha" "subList": [ { "checked": false, "name": "leaks" }, { "checked": false, "name": "pipes" }, { "checked": false, "name": "toilets" }, { "checked": false, "name": "taps" } ] }, { "checked": false, "name": "Beta", "subList": [ { "checked": false, "name": "leaks" }, { "checked": false, "name": "pipes" }, { "checked": false, "name": "toilets" }, { "checked": false, "name": "taps" } ] } }]