Tuesday, 4 October 2016

Variables and Type conversion

Variables

When you know you will need to change some data, you have to use a variable.

var variableNumber: Int = 420
You have to declare constants using let and  variables using var.
Type Conversion 
Sometimes you will have data which need to be converted it to another format.
var first: Int = 1000 // variable first with int value 1000

var second: Double = 122.5 // variable second with value 122.5
first =  Int(second) // Type conversion of second to Integer

No comments:

Post a Comment