https://kotlinlang.org logo
j

jian

03/23/2016, 1:17 AM
Copy code
import java.util.ArrayList

fun main(args: Array<String>) {
    val names = listOf<String>()
    val results = names.reduce { name1, name2 ->
        "${name1} ${name2}"
    }
    print(results)
}
Exception in thread "main" java.lang.UnsupportedOperationException: Empty iterable can't be reduced.
at Simplest_versionKt.main(Simplest version.kt:16) WTF…. The compiler not have any error at compiler time…… when I have a exception.