More Kotlin vs Java puzzlers

This commit is contained in:
Andrey Breslav
2011-11-12 18:37:06 +04:00
parent 3f6838be36
commit 89fa7cd29a
12 changed files with 154 additions and 0 deletions
+12
View File
@@ -11,6 +11,12 @@ fun array(vararg array : Float) = array
fun Any?.identityEquals(other : Any?) = this === other
fun <T : Any> T?.npe() : T {
if (this == null)
throw NullPointerException()
return this;
}
namespace io {
import java.io.*
@@ -46,4 +52,10 @@ namespace io {
}
return stdin?.readLine()
}
}
namespace string {
fun String.replaceAll(pattern : String, replacement : String) : String {
return java.util.regex.Pattern.compile(pattern).matcher(this).replaceAll(replacement).npe()
}
}