Overview - Semicolons are optional behavior
What is it?
In Swift, semicolons are used to separate multiple statements on the same line, but they are not required at the end of each statement on separate lines. This means you can write code with or without semicolons depending on how you format your code. Swift's compiler understands where one statement ends and another begins without needing semicolons most of the time.
Why it matters
This flexibility makes Swift code cleaner and easier to read, reducing clutter from unnecessary punctuation. Without this behavior, every line would need a semicolon, making code look busier and harder to scan quickly. It also helps beginners write code without worrying about small syntax details, letting them focus on learning programming concepts.
Where it fits
Before learning about semicolons, you should understand basic Swift syntax and how statements work. After this, you can explore more complex Swift syntax rules, like control flow and function definitions, where statement separation matters more.