Silver (Swift) Character Datatype - Type Mismatch Error

Just plugging in some code from the Swift documentation and ran through a few issues. I can declare a variable with the Character datatype and it will compile fine.

var letter2: Character 
print(typeOf(letter2))        // Swift.Character

But as soon as I attempt to initialize it, I receive an error.

letter2 = "a" // Type mismatch, expected ‘Character’

Same error occurs when declaring and initializing a Character datatype.

var letter1: Character = "s" // Type mismatch, expected ‘Character’

Thanks for taking a gander. :nerd_face:

What platform is this?

Fixed my adding an explicit cast operator.

Only ToDo left is to enface that the assigned string is, in fact, a single Unicode character. a lot easier said than done; I have code for that in Elements RTL, but right now Swift Base Library doesn’t depend on Elements RTl. Maybe the time has finally come to change that…

1 Like

In for Friday, or if you want tk grab SBL yourself from GitGub and build it locally.

For some fun and advanced Unicode APIs in Elements RTL that also work in Swift, check out Unicode and You.

Using Waters currently.

1 Like

Nice article Marc! It is indeed not as simple as it seems! :nerd_face:

1 Like