dropLast
Returns a subsequence of this char sequence with the last n characters removed.
Since Kotlin
1.0Throws
if n is negative.
Samples
import java.util.Locale
import kotlin.test.*
fun main() {
//sampleStart
val string = "<<<First Grade>>>"
println(string.drop(6)) // st Grade>>>
println(string.dropLast(6)) // <<<First Gr
println(string.dropWhile { !it.isLetter() }) // First Grade>>>
println(string.dropLastWhile { !it.isLetter() }) // <<<First Grade
//sampleEnd
}
Returns a string with the last n characters removed.
Since Kotlin
1.0Throws
if n is negative.
Samples
import java.util.Locale
import kotlin.test.*
fun main() {
//sampleStart
val string = "<<<First Grade>>>"
println(string.drop(6)) // st Grade>>>
println(string.dropLast(6)) // <<<First Gr
println(string.dropWhile { !it.isLetter() }) // First Grade>>>
println(string.dropLastWhile { !it.isLetter() }) // <<<First Grade
//sampleEnd
}