Add CharSequence.subSequence
This is done primarily for JVM interoperability, otherwise it's impossible to inherit from CharSequence there. On JS subSequence at the moment just invokes substring. #KT-5956 Fixed
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package foo
|
||||
|
||||
fun box(): String {
|
||||
val kotlin: String = "kotlin"
|
||||
|
||||
if (kotlin.subSequence(0, kotlin.length()) != kotlin) return "Fail 0"
|
||||
|
||||
val kot: CharSequence = kotlin.subSequence(0, 3)
|
||||
if (kot.toString() != "kot") return "Fail 1: $kot"
|
||||
|
||||
val tlin = (kotlin : CharSequence).subSequence(2, 6)
|
||||
if (tlin.toString() != "tlin") return "Fail 2: $tlin"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user