Skip to content

Semicolons in Swift

New Course Coming Soon:

Get Really Good at Git

This tutorial belongs to the Swift series

In Swift, semicolons are optional.

You can write statements on separate lines, and you don’t need to add a semicolon:

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

You can add a semicolon, but it adds nothing meaningful in this case:

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

But if you want to write more than one statement on the same line, then you need to add a semicolon:

var a = 2; let b = 3
Are you intimidated by Git? Can’t figure out merge vs rebase? Are you afraid of screwing up something any time you have to do something in Git? Do you rely on ChatGPT or random people’s answer on StackOverflow to fix your problems? Your coworkers are tired of explaining Git to you all the time? Git is something we all need to use, but few of us really master it. I created this course to improve your Git (and GitHub) knowledge at a radical level. A course that helps you feel less frustrated with Git. Launching Summer 2024. Join the waiting list!
→ Get my Swift Handbook

Here is how can I help you: