Mid-Level
August 19, 2026Spot the bug: Android
One snippet. Find the bug, or prove there isn't one.
kotlin
1import androidx.lifecycle.ViewModel
2import kotlinx.coroutines.GlobalScope
3import kotlinx.coroutines.flow.MutableStateFlow
4import kotlinx.coroutines.flow.StateFlow
5import kotlinx.coroutines.flow.asStateFlow
6import kotlinx.coroutines.launch
7
8class UserViewModel(private val repository: UserRepository) : ViewModel() {
9
10 private val _user = MutableStateFlow<User?>(null)
11 val user: StateFlow<User?> = _user.asStateFlow()
12
13 fun loadUser(id: String) {
14 GlobalScope.launch {
15 _user.value = repository.fetchUser(id)
16 }
17 }
18}Click the lines that carry the problem.
Your verdict
One attempt per day. The answer shows up right after.
Keep your streak
Create an account to keep your streak and track your progress.