Lessons learned while converting to Kotlin with Android Studio
Benjamin Baxter
2848

In regards to this line, you said Kotlins type safety should be smarter:

private val TIMER_DELAY = 3000L

Well, that’s just how type inference works. In Java, 3000 could be an integer, or a long. If you don’t specify the type, Kotlin tries to infer as much as it can and in this case makes it an Int. One could argue that it is being cast appropriately. If you want a Long, either use the L or give the type explicitly:

private val TIMER_DELAY: Long = 3000
Show your support

Clapping shows how much you appreciated Adam McNeilly’s story.