This can be useful to preserve the original function's return type.
My use case:
interface InterfaceWithUnitMethod{
fun unitMethod()
}
class MyFragment() : Fragment(), InterfaceWithUnitMethod{
override fun unitMethod() = runWithPermissions(...){
...
}
}
The override will only work if the return type matches the interface's, that is, Unit. Therefore, the previous Any? return type won't work in this scenario.
This can be useful to preserve the original function's return type. My use case:
The
override
will only work if the return type matches theinterface
's, that is,Unit
. Therefore, the previousAny?
return type won't work in this scenario.