Skip to content

Instantly share code, notes, and snippets.

@dimatarelkin
Created February 8, 2018 13:53
Show Gist options
  • Save dimatarelkin/925dfb569536cd5d968edbc9ca580324 to your computer and use it in GitHub Desktop.
Save dimatarelkin/925dfb569536cd5d968edbc9ca580324 to your computer and use it in GitHub Desktop.
let digitNames = [
0: "Zero", 1: "One", 2: "Two", 3: "Three", 4: "Four",
5: "Five", 6: "Six", 7: "Seven", 8: "Eight", 9: "Nine"
]
let numbers = [124]
let strings = numbers.map { (number) -> String in
var number = number
var output = ""
repeat {
if let digit = digitNames[number % 10] {
output = digit + output //справа налево
number /= 10
}
} while number > 0
return output
}
print(strings)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment