天天看點

Swift教程之運算符

50 : 20)

//7、範圍運算符

//封閉範圍運算符(包含a和b)

for index in 1...5 {

print("\(index) times 5 is \(index * 5)")

}

//半封閉的區域運算符(標頭不包尾)

let names = ["Anna", "Alex", "Brian", "Jack"]

let count = names.count

for i in 0..<count

{

print("Person \(i) is called \(names[i])")

繼續閱讀