fun Char.isDigit(): Boolean
Returns true
if this character (Unicode code point) is a digit.
import kotlin.test.*
import java.util.*
fun main(args: Array<String>) {
//sampleStart
val chars = listOf('a', '+', '1')
val (digits, notDigits) = chars.partition { it.isDigit() }
println(digits) // [1]
println(notDigits) // [a, +]
//sampleEnd
}
Returns true
if this character (Unicode code point) is a digit.
© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/is-digit.html