Simple Values:
Use "let" to make a constant.
Use "var" to make a variable.
var variableOne = 30
variableOne = 165
let constantOne = 12
Remember you don't have to write the type of variable explicitly. But if you do here is how to write:
let implicitInteger = 70
let implicitDouble = 70.0
let explicitDouble: Double = 70
But if you need to convert a value to a different type, you must then explicitly make an instance of the desired type.
let label = "This is the integer value:"
let integerValue = 94
let theString = label + String(integerValue)
From: Apple Inc. “The Swift Programming Language.” iBooks. https://itun.es/gb/jEUH0.l
No comments:
Post a Comment