<Why doesn't Kotlin treat numbers as "Int" by defa...
# stackoverflow
u
Why doesn't Kotlin treat numbers as "Int" by default inside sumOf function lambda? In the below code: val sum = listOf(1, 2, 3).sumOf { if (it % 2 == 0) 1 else 0 } Kotlin gives the following error: Kotlin: Overload resolution ambiguity: public inline fun Iterable.sumOf(selector: (TypeVariable(T)) -> Int): Int defined in kotlin.collections public inline fun Iterable.sumOf(selector: (TypeVariable(T)) -> Long): Long defined in kotlin.collections Playground If I explicitly use toInt(), the error is gone...