
3
3
.
.
2
2
D
D
a
a
t
t
a
a
T
T
y
y
p
p
e
e
s
s
Int/UInt are aliases for Int32/UInt32 or Int64/ UInt64 (depending if the platform is 32-bit or 64-bit respectively).
Literal is string representation of both data type and data value: 10, "John", ["AUDI", "FIAT"]
Literal notations are different ways of constructing literals that represent the same data type: 10, +10, 012 or 0xA.
Literals
Decimal: 65 Hexadecimal: 0x41 Octal: 0o101 Binary: 0b1000001
Basic: 65.4 Scientific: 0.654E+2
Swift has no distinction between primitive data types (like int in java) and non-primitive data types (like String in java).
All of the below Data Types are implemented as Structures.
Scalar Data Types
Int, Int8, Int16, Int32, Int64
UInt, UInt8, UInt16, UInt32, UInt64
var value : Double = 65.4
var value : String = "Hello \(name) \n"
Class for storing constant strings.
var value : [String] = ["John", "Bill"]
Data Types & Literals
//GENERAL
var value1 : Int? = nil //Nil Literal
var value2 : Bool = true //Boolean Literal: true, false
//NUMBERS
var value3 : Int = -65 //Integer Literal: 0x41 0o101 0b1000001
var value4 : UInt = 65 //Integer Literal: 0x41 0o101 0b1000001
var value5 : Float = 65.4 //Float Literal: 0.654E+2
var value6 : Double = 65.4 //Float Literal: 0.654E+2
//COLLECTIONS
var value7 : String = "Hello \(name) \n" //String
var value8 : [String] = ["John", "Bill"] //Array