Reputation: 1622
In C++ Qt framework, Qchar type has method named isNonCharacter() which Returns true if the QChar is a non-character. Is there any similar method for Kotlin Char type.
Upvotes: 2
Views: 485
Reputation: 18577
Kotlin provides a Char.isDefined() extension method that seems to do just what you want (or at least, the direct opposite).
So you can do e.g.:
val c = 10000.toChar()
if (!c.isDefined())
throw Exception("Char is not defined")
(This function is available in Kotlin/JVM and Kotlin/Native, but not in Kotlin/JS yet.)
Upvotes: 1