Variables in Swift 3

In this article you can get understanding of how to work with variables in Swift 3
You can learn how to define variable and understanding different types of variable

You can define integer variable without specifying the data type

You can see the following output
The result is 5

Integar Data Type

You can define the integer variable in following way and do the operations

Double Data Type

Your output for the above code
The result is 5.3

Float Data Type

Boolean Data Type

You can define the Boolean data type in following way. Boolean data type can have only two values True or False

You will have following output for above code
Value of isValid: true

String Data Type

Swift 3 has the String data type to work with string. In this example you can see how to define String variable and contact two string variables

In our Playground you can have the following output
Hello World

Leave a Reply

Your email address will not be published. Required fields are marked *