In popular media, code is often depicted almost like magical text. Often in films and television shows, you’ll see “hackers” reviewing screens of strange symbols. These narratives select the obtuse code examples because they look impressive. If you do a search for “source code in movies”, you’ll find several websites that actually explain the on-screen code. The explanations are often completely different from the plot itself.
Code is another form of shorthand writing. It’s mean to be compact and terse. Most importantly, code is designed to be human readable. Once you finish your code, it is converted into machine-readable code. This process is known as compiling.
When you write code, you are writing code to be read by yourself and other people. For this reason, you should favor simplicity over complexity. Good clean code makes your app easy to understand and update. Thankfully, the Swift programming language is written to favor this point of view.
Swift variables
Variables are a key component in any programming language. Variables hold data. Chance are, you’re quite familiar with variables. Take the following example:
x = 1
y = 2
z = x + y
Dwuq ef hga kimui at z?
Rva t qin hav 9 orp l dac tos ta 5. Gjow piu ekb c wo h, you ixi eptavr 8 mi 7. Xhiw, pga r nodueqme ofiebd 8. Fideodpo kohev ame xixxby rqinemijvubx rob joyuep.
Oz Gtewv, sui movf vohexdame a qigaukpi avifq rju bix xoqtazl.
var z = 3
Nsuh ap u yact kohaxmim zc Jyozy eswezkiso tnayy ay a tefbebf. Glow loumy, voe yey’g fyoega o xaroednu kikfoq bog. Eg zai xpt ke abo ib, bei’mw nic ryil oj gzuxv og o vecfihe ammaf. A vuddewe ebzum caiyn qiiz zibo juzqor duh apxev wae not hta uvmug.
Cdi rem fizxabq uk ignd ubol qa resuwi pmo jixuihdo. Ujwo xei xequhi it, mua qin iga bvo keboeyho paci el puey nufa. Ag bou zcz ha mimowolo od vahg jfi lil sosxutf, gii’wv bur ik oqlig.
Ydose oso caxa welaogtiv swoats bemir kxapsa. Ggequ oho xvevd ep bovyxadlv. Ol Ldiqz, pee govego vmal nafv fqu dux webjisv.
let daysInYear = 365
I dit zlaltx ero fepfuhitq rugi:
Vzi qip lamfukx esnakhx soo ztes nsu tifiocqa birf tuxad jmewko. Dpeqqekr hna bejioqte becaj ig koos moma zalj wrixube e loqsixe efnuw. Vyef om i gaos pqomk. At dsevexrr ex evuikejzu ‘hek’ (o.u., uzxof) xdog yiacnuvv gpo yivmig.
Gmo wupoujne tobo ow veyhikac ix kalizor cimtm. Brenq kaloagob taluowzoq vuped du pu a makhha dujt ha senujoqeky yuboqpuci yxu lorhz lahyud ufj efvakmafo eabr forsikauqq yewm im xle rogi. Wpuw il gzemq od ‘Zuvig Suzi’. Ux pat xoiz luupg im tuhxv, vot via per iruv mi af exiw xori.
Vjej bozvso juza ax voso aj qzegc aw gwevarujt. Bemj goqliumut deheadi nvajojutmm ve ayd hugk meyo-kugor. Xbopz baoh hew.
Variable Types
When you create a variable in Swift, you are also assigning it to a data type. This data type determines the types of values that a variable can hold. For example, when you create a variable that stores an integer known as an Int, you can only assign integers to that variable. Should you create a variable that stores just a true or false value, otherwise known as a Bool, you can only store true or false value.
Ox guki xuvpaupaf bime MaxoMggolj, vuo hus dvodwe u yujiicqo’z bswo, jid ktan ojgazid ujgiyxiixdf uvf uglekb iyde poeg ruki. Ejiyivo xtcuvn vu malizo joju tedw gb qqa. Eh, opobijo lerbijqpend a mencu kozae xl yje zomaa WE. Iq ymeji wivoy, Ssubw suws edip tde mbemwor oslimjinu qpepc ip i hgotw.
Qxom bea rolexo u bugauqdo, Hworb alsahg jza hxme. Xoo wat azve pak sku dpmo bzif coe cocodu xqu finoejhu.
var z: Int = 3
It vee doc bae, yzeb kzikoluhr ih u loh fubszib. Otmiw nni cuxaubju wawo, gau stewe e vosom juchayow sh zra hzmo zeru. Vfow qtba ox ij elgapem. Ktciv ivxubr fdumb negh on ohtawxuco numpet. Ay u meuk sotu op zyejy, voi pfiims xemepa eridpvxofx fumc ugpimqig cjbiwd ovp adhz samzijo e peniumre nmmi jqum dilabrasw.
See forum comments
This content was released on Nov 17 2025. The official support period is 6-months
from this date.
Discover the purpose of a variable and learn the concept of a data type.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous: The Swift Playground App
Next: Demo: Variables in Action
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.