toHashSet

Returns a new HashSet of all characters.

fun CharSequence.toHashSet(): HashSet<Char>(source)
fun main() {
    val text = "hello world"
    val uniqueChars: HashSet<Char> = text.toHashSet()

    println(uniqueChars)   // prints: [h, e, l, o,  , w, r, d]
}

Source