Variables
Integer
Integers are whole numbers. For example, 1, 6, -5, 45. Integer variable must be declared before they are used. Two prefixes are used depending on whether the variable is to change during the program operation. Use let if the variable doesn't change and use var if the variable does change.
let one : Int = 0
var two: Int = 0
var three = 0
The default size of the Int variable depends om the machine. For a 64 bit machine/operating system the Int variable will hold a 64 bit number. Option include Int8, Int 16, Int 32 and Int 64. The integer may also be defined at an unsigned integer, that is a positive integer. These are described as UInt8, UInt16, UInt32 and UInt 64. With more bits available for the storage of an int allows a bigger range of values.
Double and Float
Other types of number variables are float and double. These are very simliar except for the range of numbers. Float is has the smaller range of values. The Double allows a much bigger range. The default is a Double if the type isn't specified.
let four: Float = 1.0
var five: Double = 2.0
var six = 3.0
String
A String is a collection of characters. Since Unicode characters can be included in a String variable the length of a string or the position of a character within a string isn't easily defined.
Boolean
Decimal
Comments, Corrections, Suggestions: David Bourne (david@boomer.org)
My iOS and tvOS Apps and iBooks