Monday

Variables in swift : syntax with example



In all types of programming languages a variable is a container which holds the value
while the swift program is executed. A variable is assigned with a datatype.
Variable is a name of memory location. 


Swift 6 has a specific type:
  • Character
  • Int or UInt
  • Float 
  • Double
  • Bool
  • String


Variable declaration:


Syntax : var variable_name = <initial_value>


Example : var int a = 10
print(a); 


Result : 10


Swift 4 also allows to define various other types of variables, which we will cover in another post 
such as Optional, Array, Dictionaries, Structures, and Classes.

0 comments:

Post a Comment