[swift-users] CharacterSet vs Set<Character>

Jean-Denis Muys jdmuys at gmail.com
Sun Oct 2 13:02:37 CDT 2016

I was playing with CharacterSet, and I came up with:

let vowels = CharacterSet(charactersIn: "AEIOU")

let char: Character = "E"


That last line doesn't compile: I get "*cannot convert value of type
'Character' to expected argument type 'UnicodeScalar'*"

The problem is, I could not find a simple way to convert from a character
to a unicodeScalar. The best I found is the very ugly:


Did I miss anything? Does it have to be that horrific?

If so, I find using Set much better:

let vowelsSet: Set<Character> = Set("AEIOU".characters)


I must have missed something. Any suggestion welcome

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161002/c9e80286/attachment.html>

More information about the swift-users mailing list