Using the Kotlin Result union type for the first t...
# getting-started
c
Using the Kotlin Result union type for the first time.
Copy code
val response = someUseCase.getFoo()
      response.onSuccess {
        state.list.addAll(response.getOrDefault(emptyList()))
      }.onFailure {
        state.errorMessage = it.message
      }
If my response is of type Result<List<String>> why do I need to do
response.getOrDefault
? why can't I just do response.get()? Here is my useCase getFoo
Copy code
suspend fun getFoo(): Result<List<String>> {
j
You should not reference response inside the on success block. Reference
it
Instead!
c
lmao. that was it
😄 2
thank you!