The Swift 3 Programming Language – A Swift Tour

Implicit And Explicit Variable Declaration

// Implicit integer variable declaration
let implicitInteger = 70

// Implicit double variable declaration
let implicitDouble = 70.0

// Explicit double variable declaration
let explictDouble: Double = 70

Experiment - Create a constant with explicit type of Float and a value of 4

let myFloatVar: Float = 4.0

Example of Explicit Conversion

// implicit string var declaration
let label = "The width is "

// implicit int var declaration
let width = 94

// explicit conversion & applying operation
let widthLabel = label + String(width)

Experiment - Try removing the conversion to String from the last line. What error do you get?

Error we get is as follows.

binary operator '+' cannot be applied to operands 
of type 'String' and 'Int'

Click here to open actual swift-playground file for above illustration