dropLastWhile

Common
JVM
JS
Native
1.0
inline fun CharSequence.dropLastWhile(
    predicate: (Char) -> Boolean
): CharSequence

(source)

Returns a subsequence of this char sequence containing all characters except last characters that satisfy the given predicate.

import java.util.Locale
import kotlin.test.*

fun main(args: Array<String>) {
//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
}
Common
JVM
JS
Native
1.0
inline fun String.dropLastWhile(
    predicate: (Char) -> Boolean
): String

(source)

Returns a string containing all characters except last characters that satisfy the given predicate.

import java.util.Locale
import kotlin.test.*

fun main(args: Array<String>) {
//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
}