Can I get rid of that ugly line with the `@Suppres...
# announcements
n
Can I get rid of that ugly line with the
@Suppress
in https://pl.kotl.in/xmmqu1Wqf ? It is unreachable but without it, I get a type mismatch error.
r
this looks a bit better I guess? Also way more readable not sure if there is some better way
Copy code
fun <T> retry (run: () -> T) : T {
    lateinit var lastError: Throwable

    repeat(5) {
        try {
            return run()
        } catch (currentError: Throwable) {
            lastError = currentError
        }
    }

    throw lastError
}

retry {
    println("Hello, world!!!")
}
compiler doesn't scream at me for the lateinit, so I guess it can figure out that it will be set 😄
🙌 1
n
great idea, it works, thanks!!