isDigit

expect fun Char.isDigit(): Boolean

Returns true if this character is a digit.

A character is considered to be a digit if its category is CharCategory.DECIMAL_DIGIT_NUMBER.

Since Kotlin

1.5

Samples

import samples.*
import java.util.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   val chars = listOf('a', '+', '1')
val (digits, notDigits) = chars.partition { it.isDigit() }
assertPrints(digits, "[1]")
assertPrints(notDigits, "[a, +]") 
   //sampleEnd
}
actual inline fun Char.isDigit(): Boolean

Returns true if this character is a digit.

A character is considered to be a digit if its category is CharCategory.DECIMAL_DIGIT_NUMBER.

Samples

import samples.*
import java.util.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   val chars = listOf('a', '+', '1')
val (digits, notDigits) = chars.partition { it.isDigit() }
assertPrints(digits, "[1]")
assertPrints(notDigits, "[a, +]") 
   //sampleEnd
}
actual fun Char.isDigit(): Boolean

Returns true if this character is a digit.

A character is considered to be a digit if its category is CharCategory.DECIMAL_DIGIT_NUMBER.

Since Kotlin

1.5

Samples

import samples.*
import java.util.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   val chars = listOf('a', '+', '1')
val (digits, notDigits) = chars.partition { it.isDigit() }
assertPrints(digits, "[1]")
assertPrints(notDigits, "[a, +]") 
   //sampleEnd
}
actual fun Char.isDigit(): Boolean

Returns true if this character is a digit.

A character is considered to be a digit if its category is CharCategory.DECIMAL_DIGIT_NUMBER.

Samples

import samples.*
import java.util.*
import kotlin.test.*
fun main() { 
   //sampleStart 
   val chars = listOf('a', '+', '1')
val (digits, notDigits) = chars.partition { it.isDigit() }
assertPrints(digits, "[1]")
assertPrints(notDigits, "[a, +]") 
   //sampleEnd
}