0

How can i convert an integer say 0 to a , 1 to b , 2 to c in Swift . I know in C++ and Python but could not find a straight forward way in swift

C++ code below

  char a = 0 + 97;
  char b = 1 + 97;
  • 1
    It depends on exactly what you're trying to achieve, but the general answer is: "don't do this". Most of the world's characters (by both quantity and frequency of use) aren't ASCII. You shouldn't be hard coding things like this. – Alexander May 23 '20 at 17:45

1 Answers1

3

You can achieve the same thing in Swift like this:

let a = Character(UnicodeScalar(0 + 97))
let b = Character(UnicodeScalar(1 + 97))
Mo Abdul-Hameed
  • 6,030
  • 2
  • 23
  • 36