Welcome to the another most interactive article on Swift Programing langauge.
In this article we will learn about what is Swift comments, types of Swift comments and how to use Swift comments. So without wasting any time let's dive in!!
What is Swift Comments?
In other words we can say that, Swift comments are like a hints that we can use to make our coding more understandable.
Types of Comments in Swift
In Swift Programing langauge, there are two types of comments or we can say two ways to add comments in Swift;
Single Line Comment
Any text which begins with two forward slashes // is said to be Swift single line comment.
Swift Single Line Comment Example;
// create a variable
var name = "Welcome to Answersjet"
// print the value
Welcome to Answersjet
Here, both // create a variable and // print the value are the example of Single Line Comment in Swift.
Multi Line comment
Any text which begins with forward slash followed by an asterisk and ends with asterisk followed by forward slash is said to be Swift multi line comment.
Swift Multi line comment Example;
/* create a variable
to store the pension of Government employees
var pension = 7000
Here /* create a variable to store the pension of Government employees/* is an example of Multi line comment in Swift.
Above we have discussed about what is Swift comments, types of Swift comments and how to use Swift comments. Swift comments are those portions of program which are completely ignored and not executed by the Swift interpreter and compiler. In Swift Programing langauge, there are two types of comments i.e., single line and multi line comments.