Skip to content

Files

Latest commit

 

History

History
37 lines (35 loc) · 596 Bytes

README.md

File metadata and controls

37 lines (35 loc) · 596 Bytes

Swift Training

Declaring Constants and Variables

  • Use let to make a constant and var to make a variable
let double: Double = 3.14
// double = 3 // Error: You can't reassign a let
var number = 0
number = 1 // It's OK, You can reassign a var

Numeric Type Conversion

let int = 8 // int == Int
let double = 3.14 // double == Double

Strings

/// one line
let helloSwift = "Hello Swift!"
/// multi line
let hiThere = """
Hi
Swift!
"""

Control Flow

let value = 101
if value%2 == 0 {
  print("")
} else {
  print("")
}