I have the following generic code: ```import kotl...
# general-advice
k
I have the following generic code:
Copy code
import kotlin.coroutines.CoroutineContext

abstract class ResultUseCase<in P, out R> {
    protected abstract val coroutineContext: CoroutineContext

    abstract suspend fun doWork(param: P): R

    suspend operator fun invoke(param: P): R = doWork(param)
}
When I have an implementation that has no parameters that it needs, I used
Unit
as the
I
generic. However, when invoking
doWork
or using the invoke operator I have to specifically pass
Unit
to it. Is there a way to not have to pass
Unit
to it? Maybe some other generic or so?
e
add an extension,
Copy code
suspend fun <R> ResultUseCase<Unit, R>.doWork(): R = doWork(Unit)
1
k
Thank you!