Skip to content

Instantly share code, notes, and snippets.

@natecook1000
Last active October 14, 2016 10:07
Show Gist options
  • Save natecook1000/d9537ae3df8e1b51e34a to your computer and use it in GitHub Desktop.
Save natecook1000/d9537ae3df8e1b51e34a to your computer and use it in GitHub Desktop.
// If we extend UnicodeScalar to conform to ForwardIndexType, we can create and map a Range.
extension UnicodeScalar: ForwardIndexType {
public func successor() -> UnicodeScalar {
return UnicodeScalar(value + 1)
}
}
let alphabet = ("A"..."Z" as Range).map { String($0) }
// ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment