Type checking has run into a recursive in kotlin

For anyone seeing this compiler warning, it may be as simple as nesting your code inside a Unit aka { ... }

Kotlin allows us to assign functions:

fun doSomethingElse() = doSomething()
fun doSomething() { }

However, this doesn’t work if we’re calling the function recursively:

fun recursiveFunction(int: Int) =
    when (int) {
        1 -> { }
        else -> recursiveFunction()
    }

The fix is simple:

fun recursiveFunction(int: Int) {
    when (int) {
        1 -> { }
        else -> recursiveFunction()
    }
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)