Minor. Fix test

This commit is contained in:
Ilmir Usmanov
2020-05-08 16:35:10 +02:00
parent e92adf3d4e
commit d6d331de2a
7 changed files with 19 additions and 18 deletions
@@ -0,0 +1,29 @@
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
// FILE: 1.kt
inline fun List<String?>.forEachNotNull(s: String, fn: (String, String) -> Unit) {
for (x in this) {
fn(s, x ?: continue)
}
}
inline fun List<String?>.forEachUntilNull(s: String, fn: (String, String) -> Unit) {
for (x in this) {
fn(s, x ?: break)
}
}
// FILE: 2.kt
fun box(): String {
var res = ""
listOf("O", null, "K").forEachNotNull("|") { a, b ->
res += a + b
}
if (res != "|O|K") return res
res = ""
listOf("O", null, "K").forEachUntilNull("|") { a, b ->
res += a + b
}
if (res != "|O") return res
return "OK"
}