Lesson 10 Colon or No Colon

Recently in the videos, I see the colon being used at the end. Is that something I should get in the habit of doing? If so, when and where do they need to be?

Colon : or semi-colon ; ? A colon at the end of a statement would be syntax error that won’t compile. A semi-colon at the end of a statement is optional (though required if multiple statements are on one line) but discouraged by standard Swift style conventions.

Any examples of what you are seeing?

1 Like

usually its a habitual thing, like me coming from various programming languages its usual to put semi colon ( ; )at the end of each line/statement so i kinda forget and apply it on Swift as well because it doesn’t cause an error, its not really needed though

Sorry. Yes, the semi colon. I heard that with Swift it’s an optional thing? When I was trying to learn HTML CSS there was always a semicolon at the end of everything! Thanks so much for the reply!

1 Like