if-else while for

2020-05-18  本文已影响0人  奇怪的知识增加了

swift系列课程

if-else
let age = 4
if age >= 22 {
}
else if age >=18 {
}
else {
}
while
var num = 5
while num > 0 {
       print("num is \(num)")
       num -= 1
}

var num = -1
repat {
         print("num is \(num)")
} while num >0//打印了一次
for
let names = ["kkk","bbb","ccc","ddd"]
for i in 0...3 {
      print(names[I])
}

let range = 1...3
for i in range {
      print(names[I])
}

let a = 1
var b = 2
for i in a...b {
     print(names[I])
}


注释

image.png
上一篇下一篇

猜你喜欢

热点阅读