Nicolas Mariano Obregon
11/24/2020, 3:33 PMrunCatching
, something like this below, how should I define my interface method signature in order to return whatever the runCatching returns? I hope I was clear enough. Thanks in advanced
interface IMyInterface {
suspend fun myFunction()
}
class MyClass : IMyInterface {
override suspend fun myFunction() = runCatching {
}.onFailure { ... }.getOrThrow()
}
Vampire
11/24/2020, 3:35 PMNicolas Mariano Obregon
11/24/2020, 3:45 PMinterface IMyInterface {
suspend fun myFunction()
}
class MyClass : IMyInterface {
override suspend fun myFunction() = runCatching {
...
}.onFailure { ... }.getOrThrow()
}
Vampire
11/24/2020, 3:49 PMrunCatching
is the return type.StavFX
11/24/2020, 4:03 PMNicolas Mariano Obregon
11/24/2020, 4:55 PM}.onFailure { ... }.getOrThrow()
And the compiler was complaining, but after adding those, it worked fine. Thanks!