79140134

Date: 2024-10-30 07:57:04
Score: 2
Natty:
Report link

In the java when we want to overload the function we have to change it's signature. Which is function name or parameter. When we define suspend in kotlin we just identify of the environment of function where it can be run like coroutine. You can check this link for information: java signature

To give example you can change like that:

fun foo(a: Int, b: Int): Int {
    return a + b
}
suspend fun foo(a: Int, b: Int, isSuspend: boolean): Result<Int> {
    if(isSuspend) {
        delay(100)
        return Result.success( a + b)
    }else {
        return Result.failure("Call suspend")
    }
}
Reasons:
  • Blacklisted phrase (1): this link
  • RegEx Blacklisted phrase (1): check this link
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Yakup Kavak