🐛
P0 Bug Hunter
Find the bugs in each code snippet
←→NavigateAShow remainingRReset
🎯Bug Formula: What's wrong → What breaks for the user → The fix → The trade-off
Find the bugs in each code snippet
1class SearchViewModel(2 private val api: HotelSearchApi3) : ViewModel() {45 val uiState = MutableStateFlow(SearchUiState())67 fun search(query: String) {8 viewModelScope.launch {9 uiState.value = uiState.value.copy(isLoading = true)10 try {11 val response = api.searchHotels(query)12 val hotels = response.body()!!.results13 uiState.value = uiState.value.copy(14 isLoading = false,15 hotels = hotels16 )17 } catch (e: Exception) {18 uiState.value = uiState.value.copy(19 isLoading = false,20 error = "Something went wrong"21 )22 }23 }24 }25}Find the bugs in each code snippet
1class SearchViewModel(2 private val api: HotelSearchApi3) : ViewModel() {45 val uiState = MutableStateFlow(SearchUiState())67 fun search(query: String) {8 viewModelScope.launch {9 uiState.value = uiState.value.copy(isLoading = true)10 try {11 val response = api.searchHotels(query)12 val hotels = response.body()!!.results13 uiState.value = uiState.value.copy(14 isLoading = false,15 hotels = hotels16 )17 } catch (e: Exception) {18 uiState.value = uiState.value.copy(19 isLoading = false,20 error = "Something went wrong"21 )22 }23 }24 }25}