Swift Basic Data Types & Type Inference
5 (1)

Last Updated on November 15, 2021 by deya

Swift is strongly typed, data should either be explicitly assigned or inferred, the main basic data types that come with swift are

TypeDescription
Charactera 16-bit Unicode character like “a” or “/”
Stringrepresents textual data like “Hello”
Floatrepresents 32-bit floating-point number
Doublerepresents 64-bit floating-point number
Boollogical value: true or false
Tuplesgroups multiple values in single value
Intinteger, a whole number
UIntunsigned integer, a whole number
Int81 byte integer
Int324 bytes integer
Int648 bytes integer
UInt81 byte unsigned integer
UInt324 bytes unsigned integer
UInt648 bytes unsigned integer


On a 32-bit device, Int has the size of Int32, on 64-bit devices, Int has the size of Int64, same goes for UInt.

Swift has a feature where it can infer the type of the data directly, for example the variable level here is infered to be an Int

var level = 12

you can explicitly determine the type directly

var level: Int = 17
Click to rate this post!
[Total: 1 Average: 5]

Leave a Reply

Your email address will not be published. Required fields are marked *