← Docs
kotlin-stdlib / kotlin.text / singleOrNull

singleOrNull

Common
JVM
JS
Native
1.0
fun CharSequence . singleOrNull ( ) : Char ?
(source)

Returns single character, or null if the char sequence is empty or has more than one character.

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

(source)

Returns the single character matching the given predicate , or null if character was not found or more than one character was found.

Stay in touch:
  • Contributing to Kotlin
  • Releases
  • Press Kit
  • Security
  • Blog
  • Issue Tracker
  • Brand assets
  • Careers
Supported and developed by JetBrains .
Kotlin™ is protected under the Kotlin Foundation
and licensed under the Apache 2 license .