Swift: generate an array of (Swift) characters
It's a little cumbersome to get the initial character code (i.e. 'a'
in c / Obj-C) in Swift, but you can do it like this:
let aScalars = "a".unicodeScalars
let aCode = aScalars[aScalars.startIndex].value
let letters: [Character] = (0..<26).map {
i in Character(UnicodeScalar(aCode + i))
}
Thanks for useful answers.
I'm using one-liner version.
let xs = (97...122).map({Character(UnicodeScalar($0))})
or
let xs = (0..<26).map({Character(UnicodeScalar("a".unicodeScalars.first!.value + $0))})