single

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

fun CharSequence.single(): Char(source)
val singleChar = "A".single()
println(singleChar)           // prints: A

try {
    "AB".single()           // throws NoSuchElementException
} catch (e: NoSuchElementException) {
    println("Exception: ${e.message}")
}

Source