Variables are used to store data in memory so that we can use them in program. Variables are like container that can hold data which can be changed later. Every variable has a unique name called identifier.
Variable Declaration In Swift?
A variable declaration tells the compiler of which type, where and how much to create the storage for the variable. Declarations of variables are made using the var keyword.
Example
import Cocoavar firstvar = 68println(firstvar)
Output
68
Type Annotations
Programmers can supply a type annotation when they declare a variable, to be clear about the kind of value(s) that the declared variable can store. The general form of using this variable is:
Syntax
var variableName:<data type> = <optional initial value>
Example
import Cocoavar firstvar = 68println (firstvar)var secVar:FloatsecVar = 3.14159println (secVar)println(" 1st Value \(varA) 2nd Value \(varB) ")