takeLastWhile
Returns a subsequence of this char sequence containing last characters that satisfy the given predicate.
Since Kotlin
1.0Samples
import java.util.Locale
import kotlin.test.*
fun main() {
//sampleStart
val string = "<<<First Grade>>>"
println(string.take(8)) // <<<First
println(string.takeLast(8)) // Grade>>>
println(string.takeWhile { !it.isLetter() }) // <<<
println(string.takeLastWhile { !it.isLetter() }) // >>>
//sampleEnd
}
Returns a string containing last characters that satisfy the given predicate.
Since Kotlin
1.0Samples
import java.util.Locale
import kotlin.test.*
fun main() {
//sampleStart
val string = "<<<First Grade>>>"
println(string.take(8)) // <<<First
println(string.takeLast(8)) // Grade>>>
println(string.takeWhile { !it.isLetter() }) // <<<
println(string.takeLastWhile { !it.isLetter() }) // >>>
//sampleEnd
}