Skip to content

Commit

Permalink
refactor : 빈 식단 if문 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
huiwoo-jo committed Apr 21, 2024
1 parent 4a9a706 commit bff8fda
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ class CafeteriaViewModel(
fun updateMenuList(selectedDate: LocalDate) {
val cafeteriaList = _cafeteriaList.value ?: emptyList()
_selectedDate.value = selectedDate
val selectedMenu = cafeteriaList.find { it.date == selectedDate.toString() }?.menus
_menus.postValue(
cafeteriaList.find { it.date == selectedDate.toString() }?.menus
.takeIf { it.isNullOrEmpty() }
?.let { emptyMenu }
?: cafeteriaList.find { it.date == selectedDate.toString() }?.menus
if (selectedMenu.isNullOrEmpty()) {
emptyMenu
} else {
selectedMenu
}
)
}
}

0 comments on commit bff8fda

Please sign in to comment.