Swift: Comments

Swift Comments:

When we return to our own code even if it’s only a few hours later it might soon become difficult to understand. As a result, it’s beneficial to include a remark or reminder in our code for future self or other developers. So, we use swift comments to solve this problem.

Comments can use to clarify what the code does, give instructions for developers who will be using it, or add any other relevant annotations.

Swift have two types of comments:

  • A single line comment is denoted by two forward slashes // preceding it. It will comment out a single line:
// Prints "yes"
print("yes");

  • A single line comment can also be used after a line of code:
print("Hey");  // Prints "Hey"
  • A multiline comment is denoted by /* to begin the comment and */ to end the comment. So, it will comment out multiple lines:
/* Everything has been commented out.
print("Wow")
This isn't going to work! */

Helpful Tools:

Here are some useful tools to help you along your journey!

Setting up an IDE (Integrated Development Environment) can be difficult for beginners. The Online Compiler will enable you to run your code inside your browser without the need to install an IDE. If you need a more detailed explanation of a specific topic, the best place to find answers is in the Official Documentation.

Scroll to Top
%d bloggers like this: