Skip to content

Instantly share code, notes, and snippets.

@lukeknxt
Last active January 30, 2024 21:48
Show Gist options
  • Save lukeknxt/44f2ae5695fb73db51b5d0db66a047b2 to your computer and use it in GitHub Desktop.
Save lukeknxt/44f2ae5695fb73db51b5d0db66a047b2 to your computer and use it in GitHub Desktop.
Kotlin happily infers Any for you
data class Wrapper(val id: String)
val ids = listOf("id1", "id2")
listOf(
Wrapper("id1").id,
Wrapper("id2")
).forEach { someId -> // inferred as Any
val result = ids.find { it == someId }
// id2 will never be found, but the compiler won't tell you
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment