... 和 ..<

Posted by Genie on June 16, 2020
1
2
3
4
5
6
7
8
9
//包含10
for i in 1...10 {
    print(i)
}

//不包含10
for i in 1..<10 {
    print(i)
}
1
2
3
4
5
6
7
8
let test = "helLo"
let interval = "a"..."z"
for c in test.characters {
    if !interval.contains(String(c)) {
        print("\(c) 不是小写字母")
    }
}