Swift
Table of Contents
Basics
Declaration
Use let to make a constant and var to make a variable.
var myVariable = 42
myVariable = 50
let myConstant = 42
Type Inference
implicit and explicit
let implicitInteger = 70
let implicitDouble = 70.0
let explicitDouble: Double = 70
Data Types
IntorUInt- You can use Int32, Int64 to define 32 or 64 bit signed integer where as UInt32 or UInt64 to define 32 or 64 bit unsigned integer variables.
Float- 32-bit floating-point number
Double- 64-bit float
BoolStringCharacterOptional- Can hold either a value or no value.
Conditionals
if onSaleInferred {
print("\(nameInferred) on sale for \(priceInferred)!")
} else {
print("\(nameInferred) at regular price: \(priceInferred)!")
}