/

Semicolons in Swift

Semicolons in Swift

This tutorial is part of the Swift series.

In Swift, semicolons are optional. You can write statements on separate lines without needing to add a semicolon:

1
2
let list = ["a", "b", "c"]
var a = 2

Adding a semicolon in this case does not change anything:

1
2
let list = ["a", "b", "c"];
var a = 2;

However, if you want to write multiple statements on the same line, you must include a semicolon:

1
var a = 2; let b = 3

tags: [“swift”, “semicolons”]