Declaring Constants and Variables
In Swift language to store temporary data we have to use variables and contants.Here we use var keyword to declare variables and let keyword to declare Constants.
var myvar=5
T declare a constant variable
let x=0
You can declare multiple constants or multiple variables on a single line var x=0,y=6
Type Annotations
To define a data type we can use Type Annotations.
var Message: String
Here var Message has a type String
We can change the value of a variable anytime but the value of constant can not be changes once it is set.
Printing Constants and Variables
print method is used to print the value of varable or constants.String interpolation is used to include placeholders
print(message)
print("Welcome Amit you got a \(message)")
Comments
//This line is comment
Multiline comments start with a forward-slash followed by an asterisk (/*) and end with an asterisk followed by a forward-slash (*/):
/* here it is
Multiline comment */