Function in Swift


1) Print

print(anything)

만약 중간에 코드를 넣고 싶다면 \\([ code ]) 사용

print("the result of 5 + 3 = \\(5 + 3)")

2) random

// 1 ~ 3
let randomNumber = Int.random(in: 1 ... 3)
// 1 ~ 2
let randomNumber = Int.random(in: 1 ..< 3)
// 1 ~ 2.9999999...
let ramdomNumber = Float.ramdom(in: 1..< 3)

3) Sleep

4) Timer() ← 써야함

Swift에서 편하게

5) Debug