Basics
-
Code starts in the global scope, just like in Python.
Comments
// This is a comment.
/* This is also a comment
but is written over multiple lines. */
Use of
;
-
Swift doesnβt require you to write a semicolon (
;) after each statement in your code, although you can do so if you wish. -
Semicolons are required if you want to write multiple separate statements on a single line:
let cat = "π±"; print(cat)
// Prints "π±"
Keywords
let (constant)
-
Not modifiable at any time
let a = 10
let a = [10, 20, 30]
a.append(10) // Crash.
var
-
Modifiable at any time
var a = 10
Multiple declaration
var x = 0.0, y = 0.0, z = 0.0
var red, green, blue: Double