逆序遍历数组
for i in (0...10).reversed() {
print(i)
}
// 3 ,2,1,0
for i in stride(from: 3, through: 0, by: -1) {
print(i)
}
把字符或者字符串转成整型
func toNum(_ char: Character) -> Int {
let intValue = Int(String(char))
if let value = intValue {
return value
} else {
return 0
}
}