O'Reilly logo

Swift Quick Syntax Reference by Matthew Campbell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter    4

Code Comments

You use code comments when you want to add information to your code. With Swift, you can add a one-line code comment, multiple-line code comments, and even nested code comments.

One-Line Code Comments

Use the double backslashes (//) to start a one-line code comment. See Listing 4-1 as an example.

Listing 4-1. One-Line Code Comment

//One line code comment

You can fill up one line with these types of comments.

Multiline Comments

One-line comments are fine for quick notes about code that may need some extra information provided. But when you want to add a lengthier description, you can write over many lines at once. To write a multiline comment, you start the comment with a backslash and asterisk (/*), write the comment, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required