More Kotlin vs Java puzzlers
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user