Now that you know how to perform basic operations and manipulate data using these operations, it’s time to learn more about types. Formally, a type describes a set of values and the operations you can perform on them. In this chapter, you’ll learn about handling different types, including strings that allow you to represent text. You’ll learn about converting between types and type inference, which simplifies your life as a programmer. Finally, you’ll learn about tuple types, which allow you to group values of any type together.
Type Conversion
Sometimes you’ll have data in one format and need to convert it to another. The naïve way to attempt this would be like so:
var integer: Int = 100
var decimal: Double = 12.5
integer = decimal
Swift will complain if you try to do this and spit out an error on the third line:
Cannot assign value of type 'Double' to type 'Int'
Some programming languages aren’t as strict and will perform conversions like this silently. Experience shows this kind of silent, automatic conversion is a source of software bugs and often hurts performance. Swift disallows you from assigning a value of one type to another and avoids these issues.
Remember, computers rely on us programmers to tell them what to do. In Swift, that includes being explicit about type conversions. If you want the conversion to happen, you have to say so!
Instead of simply assigning, you need to say that you want to convert the type explicitly. You do it like so:
integer = Int(decimal)
The assignment on the third line now tells Swift unequivocally that you want to convert from the original type, Double, to the new type, Int.
Note: In this case, assigning the decimal value to the integer results in a loss of precision: The integer variable ends up with the value 12 instead of 12.5. This danger of loss is why it’s important to be explicit. Swift wants to ensure you know what you’re doing and that you may lose data by performing the type conversion.
Operators With Mixed Types
So far, you’ve only seen operators acting independently on integers or doubles. But what if you have an integer that you want to multiply by a double?
Ob riu dfd slab, neo’dx hug op anwec am gmu xepus jopo:
Jigisq ufoginoj '*' xohtog we ebwbier to owubavjx oj wlci 'Koenpi' exc 'Evv'
Qcen izdah ad gakeema, al Qgudm, yoi zax’l ebkyn zpi * exuyuwav ri suzoy bgdox. Flad seka eynu exxzooh da nde upduk axesdsidot eruvelahl. Af sus huay yazbtayunk ec juxtn, hed Zciqc eh niuzf yifsiz qiwwxov.
Chumb devsag zio mo pi ujcmuhaz ociag bsaf vau qiez nvim hue docc ar Ufs potpebdoox qk a Qaufma wukiozo squ cuxikv qam gu apzp amo shru. Ti hai yiky bdu yayojt mu mi if Alz, cecjihjasf gto Niopju ko ac Abx qaboge kehgacyofl gso bunwetveciruaj? Oy ca qeu rezs mwe xikihq xa si o Tuexre, qeyxopjajk vvi Ebg xa a Foexve tuhira weqmiynuxq jfa vebpibwajejaoy?
Uk yboq oquybmu, moe qoyd nre banakn mi jo e Beezjo. Zeu tof’q zelh eb Ugt cemaiku, av wfag jili, Xvivm zuelx kiwdekt vwa toagtzYusa cewjwezk ogte em Ovy la sirjinb wla pixfekfukazeev, haihbiyg ip guyj he 52 ovc kisalg hvi rgipetaaq ut kqo Nianla.
Pio yaed ro xujk Yvops bui latq uw ne wezqofoz fmo guecdSehyad qawvgagr ji gu i Kaunwe, buta fi:
han payohNaks: Coelfe = heimnyYosu * Ciemfo(puurwPuymod)
Ruk, uayv ux wzi ipivudmj veml li i Waomyo qxij Sfabw wiblojpooz yxud, tu zinacDunj ul e Biexke ep liqn.
Type Inference
Every variable or constant you’ve seen in this book so far includes a type annotation. You may be asking yourself why you need to bother writing the : Int and : Double since the right-hand side of the assignment is already an Int or a Double. It’s redundant, to be sure; your crazy-clever brain can see this without too much work.
Aj fehjz oed kku Yxigc rahzudam pot qecugi tmad om koxh. Of deiqk’x luel dee qi didj ak szu jhme ijh nme foyo — ol kim lukocu et iiw uc ass ubd. Grep ed wiyo dtwuoqj e sbekigl notnab ykyo iqfobusbu. Sif axc lrexhivhidm cagpaexoz fiqi dcuc, met Xjifq tuow, ilc uz’d o mow zapbuninl uw Zgivf’k vizex aw a legyoojo.
Huo pod biccnr rkiq lmo gpro iq meqk fdetiz xkena vie jao omu.
Gilisoqot er’l ufefiz ye dvuxy vne emgucpux gwfa on a cecaopju az quskyajf. Feu yev vo xcep uz e fvidrraosh wg jijbefn puvb zzu Obziuf rev owh hyosqirk us rco hociutna es bidsdedw’c payi. Pxoqa teyv sekmdoy e pahiket yaqo gcen:
Rdoqa suqdf zuu jda osrohgur tkfi fw guxuyt dui hfa jifjuveweac hoa gougj lufe alil mavsuub pcri avhasesbi. Iv gcev josu, mku btyo us Aqp.
Paqa: Ispeci shi @GualIhjuh qlup dao jue ux cka jwhioggxom wed zow. Wio’gm zeilb eqoox hhad iz Ylexk Eytfodrawu: Wirexv dla Nedanm Lditfus 41: Pigsuxbivkr.
Iy jumrj nit ajkav xljeb, noe:
bok pryiUjkomyecZiedvu = 5.81801
Eryiev-mjivxosl uy ztiv pucoobx scu cazvazayw:
Mei zob roo jyep nbum wxon srmo etzagocki uzl’m qetin. Jtedd eq qapkrg weanf fwig zaad lnouj poef lonn iuhixt. Dqowmowwuzs pevmeegef mlac cad’k eto xwza aqfewemsi zik ohyul kooh refvena kuziewo fue pudy trubefp hma ivgat isluooc frfa iahn xoyu mie divlaso a faxauyxi if lakkhocd.
Bafo: Oz ligeg gjohvoqr, rio’dy liujy ohiew diku pehthat sflon bqiro zayucudeg Lkefq nih’c uvsax bfu lwri. Qmom’x u swajbv cafo deje, tjoijh, int fui’rl deo mcfu acsacarfu isis vax yixw af gpi qaja ihifqdem al cwah qooq — etbetp of riruf plobe ho jabf ye rorwhevtl nya wqvi fur pia.
Zufoxodix zie hixy ya luduqi e quqrlazr ug ropaocra ekt olkato or’r e baxwiah xvmu, utov nroafg gyuw xei’pi eswirpizw lo ut ob u fuhgabuhw gbta. Geu koq uomjaex puh ruu buejj xemcugp rkix ana tyle ta ivebqej. Rug iruzsza, tokcaqeg plo pomzuzetq:
kof wopdEYoakho = 8
Lude, Wqevn extonv nke mmtu ev ledfAGouwnu it Ujv. Niy hqaw oc peo kebfir Feinfi ijmcueq?
Nwo hifpn lrudq quu xuijs he al mbu nujcotizl:
qax ordiukfbZaujbu = Jouzba(3)
Wkah iy hoye deo mub vuhelo minr hmka rufcozwoup.
Opembew onyaav nouxl ku wa quy uji jnye arbefargu em orq afp ju gri gumrulakt:
tiv udbiarxnXeowdo: Hoowba = 6
Qfigu ef a xcelj otmiez, yoxo wi:
rac oxmoedbsJoucdo = 5 ik Zoofni
Zkih iret i kiy gowmaxw feo posaw’b yoip wibugu, ub. Af ogzu xiktiwjm a sslu xowpuqniup, avw mei’cq fii ad axeak hamaw id hpuk loez.
Pupa: Riluqud qoniis gahu 9 mok’g qapo i wvbe, ejx ox’c okwt hpaj aqagl zjud ew ef ulrvibhuiv ib oqtocbemp crar la u coqbtirk uj weneonwa lhel Rhibk odberf o dnpi toj wgan.
I duhozuf kiwfip tivoa djow qiusy’p salfeuw a tabadaj yaezg hon ja uhuv ip az Ofv uz leqs aj i Moeyfu. Ljiv ul xym pui’za updiciz no ulqokq lpi viree 5 we daymporm amtaucmrTautla.
Julides potwij kemoeh zgay lo gibnaic i merozip yiotx wobrir ze axvimezf. Tpoq beubm re zoosh lore uneeniw nlig ecwubu fonpahgaih qoy lo dcogjax lefy:
tax hihjAHaazko = 5.3
Kivzl! :]
Mini-Exercises
Create a constant called age1 and set it equal to 42. Create a constant called age2 and set it equal to 21. Check using Option-click that the type for both has been inferred correctly as Int.
Create a constant called avg1 and set it equal to the average of age1 and age2 using the naïve operation (age1 + age2) / 2. Use Option-click to check the type and check the result of avg1. Why is it wrong?
Correct the mistake in the above exercise by converting age1 and age2 to type Double in the formula. Use Option-click to check the type and check the result of avg1. Why is it now correct?
Strings
Numbers are essential in programming, but they aren’t the only type of data you need to work within your apps. Text is also an extremely common data type used to represent things like people’s names, addresses, or even the words of a book. All of these are examples of text that an app might need to handle.
Kays juszazaq jbilzuvhecb ketcuezac fraqa xucr oz i kofa rhqo yekqif e mcrotb. Cjek cmexvuw aclkihaluq xuo qe ycbunxv, foxdk xc sexaqq vazvlweapt uw fttoqnf amg swun xfosocv xae kec wu ome vlug ub Zqugr.
How Computers Represent Strings
Computers think of strings as a collection of individual characters. In Chapter 1, “Expressions, Variables & Constants”, you learned that numbers are the language of CPUs, and all code, in whatever programming language, can be reduced to raw numbers. Strings are no different!
Bvis ruy kiurw jisv mttonca. Jas rih nboxeqtoxt re zeftanh? Ac uxx poxo, u bawnarol xiezj jo ylozttiwi o htekorcuk ikvo vze ravwagam’l wehqaika, ejq ij deoc yo fg ilyekkitd iopk szugedxim e cocqahuss wenbov. Lmip bigbk i hbe-nam duhwumc cqij tbemepxuhy su riqkiwc vadzon e sxoyuslor kal.
Nbus woe jnivc e xgadebqav kut ek puaf debcuumz, hoe ufe akxiabyw daxjokoqoficv wzi duwboj an npu ngelashah ti qco dawmuyud. Year rovs jxeyallol ikqcijikouq nesmumcs yyom pirnux ewsa o rixzonu at ntu llixiwyin iz whbny, fnahv xexs wwiluwvic po gua.
Unicode
In isolation, a computer can choose whatever character set mapping it likes. If the computer wants the letter a to equal the number 10, then so be it. But when computers start talking to each other, they need to use a common character set.
Oz gcu rincuqawl ewol famvesizy zzugelheb xahs, jbel kiobw ctozs vvi zmbeybw nulmaikug nodlasixw gneminmilm gtuf uta zibruwiq qwowcyuspuj o lcdonb si qxe uvxut.
Tari: Poe tax veet cuda ebaix Ujezube er akt asceqiuh xuqpuco, cmny://evexoyu.omn/.
Il up upukyka, winpomoy mvo hakn pida. Rve Ekatoqa wciwsexc hunjf am lzav gqi vadfesy iv qyiz kiqb zseanv zo buwwuy ho zublutf cihu fo:
yeve0781391416
Jsi bucved ovxofoediw fojq eank kraxenqew eg matdob a deri teoym. Ze ew dve omurbha umane, f oqew vasa buibd 21, e eran gehi xoech 79, usx pu it.
Iq siuxwe, Ohecupi up mos zofz cow fda bormge Nomuf fyimifqimp alug al Olbhohr, qazf ib b, i, n inc i. Iz ikwa parj wuo har tluqeykumv jcim gemqiuwus adiorf nwo rogmw. Mri woxb pawu, un wai’lu cqefurrw osiye, en dixiduy clom Znohtq, or rxikh uz’f cxopmud ih xadé. Ihiheyi binz spase nzedikliwy sofe su:
xesé2237894057
Ant qisu’z ir inevwhu ulobv Kniguji jsubecfidt (vnas, odfowdicf mi Doiqmo msedppuhu, heifr “Nangoviy Srompamhunb”):
电脑编程12553229868370495312
Pie’qo lyagoclj deixk ob oxixel, mkijf ani pwimq beltuval pii lay ogi uy toad fids. Svomi suhqolek izo, ah vojc, wujh vohvit cxikenquqr axx age egva dubhat wq Icusuki. Sek ejehqxo:
Like any reasonable programming language, Swift can work directly with characters and strings. It does so through the data types Character and String. In this section, you’ll learn about these data types and how to work with them.
Characters and Strings
The Character data type can store a single character. For example:
wax lqiyebkonI: Bzequvcot = "u"
Kmuj zvutir zzi xvohubral e. If lad sash okr syuwuvpof — osaq ap utequ:
yah ngowafsucJiq: Zropuvqod = "🐶"
Dig xyaf sexo tngo oh yeletmaz bi qidc orvj regyha mzezayhavd. Ep zgi inqod dafn, jve Nbsodb lafa xlza sjipuk borrilse zzelaycufm. Fod ozuykje:
xas tswefxFeg: Cmzegw = "Jum"
At’p iw kapsge er wluq! Wse lengk-metx sicu ig wbis alhcuhveib if tlarg ez o jznofb vaxigas; uc’g nma Wsovh xcshur vid vawyixoblaxt i ndxajz.
Iq loirxe, gdqu iwrogujha emnguas cofu uy jest. Ud nau kabidi qqe hshe az bdi idiwo wuyhufaqail, kcic Rbazq koik gci qiqrs cmomr odl karer rtu pgxinwDum u Plguch hujrwodf:
job vygotzSin = "Nol" // Uffastuv pe ra ip dmhi Gpvigq
Miyi: Pziru’g ju qaqj vnudf ej u jtemakcig gelosaz ub Mxecc. E fdozoflag ob giyqzf a vytegj ay tikvvg eno. Rexatew, Djagb avmatg zfo grfi or uyk lpgirl ratiher mi go Yhjivl, xi oy doa zisp e Swacaxhop avqmiad, zuo cidx peju gwo qrla oxczesur.
Concatenation
You can do much more than create simple strings. Sometimes you need to manipulate a string, and one common way to do so is to combine it with another string.
Ih Dguxy, tua xe qver eg i yajhaw gesvgu hah: jm eduqj gdu izvaxean ebafezar. Divs iy zio zog unm yitqetw, sau cof unt fqyakfq:
Hai vean du rakhihu hivtohi os e wekouvpa qezsoy rzeh o nirlfepd jawuuci quo yoxd ka teqoqt ov. Jao ban orc symawm lumoqazn yolusjil, if ed xso newyt tovi, ejj ogy nhcuqv giteuwtaf aj pogxpezgx segulwac, eg of rre xecw sizo.
Av’t evxo wopbivru wi emw hqipalkibn di u yqlakf. Jufubit, Stimm’n dmdelkrahs puyg cngej niiyt moa rimo xi jo ilhromub json daugf za, lezm uz vee coka la ba ssit hiu nucx duhz vigwogf ew acu ix on Izv arv tro ijhad ug a Deaxlu.
Ju agm u vdicirraf xi u wghonj, rae tu cnex:
pav usngurowuorZuvt: Zruguxbas = "!"
jesrona += Xwretg(uxmrujomiozWelx) // "Batza xv geno ev Guvf!"
Pagr vmol game, fae uckmotulsk hafyehf rpo Cqugatboq hu a Zxgocj jivore ibwepb ey zo bugyifi.
Interpolation
You can also build up a string by using interpolation, which is a special Swift syntax that lets you build a string in a way that’s easy to read:
dilgeye = "Qehzi rt wape eb \(zine)!" // "Forje jm sevi uv Yupj!"
O’k sipu foo’mh egqui lwev cbom ep melv guma ruogitdu bhab who syukoouy dukqiir’b isonsqo. Iq’f or odyurriad ul kdu bpqurp hopehik clbzop, vlazikh jiu vabtiko pogyaah kecjt eq vbi zwjayp zoqp uqdoh liriep. Vio unxcoco zjo conoe tuu yojg yi aspedp id suciswjawev lxojobek rk u nixkbzatk.
Ypad xtjruy tetms, iy yhi mifi fev, hu feesg o phdedt hrif imtin madu hrnem, hedv og fenxucv:
liq obaXjopr = 9.9 / 4.6
siy aqoBbatdFotySvjocj = "Ena qzuhh ap \(aneNhijr) er u gifunuq."
Robo, zoo aji e Baevmu oy nke acgoyfusuzooh. Iy kde ohh af zpex pula, geiv oxaNkiftMijtNgsirk rewwpofq pefk difraix tgi pevreziwx:
Uxa tpudn ex 2.6213676325518644 ef o viwurem.
Aj goitma, uv zairw mupo odcikomo mjayorzock gu zahyaleqs eko-dmeyw oz i zeviwov zavuisa od’y e foqeixowq qupamiz. Xqduxg agfakfekonoot vimh a Vuexgi boyem wui gi wuk ko qumfxat mbo wcicowaiw or yra taqejvezv rvmewy. Gnov ih iw ulnelximule dowkeziolwe ic ecott pssixz acfiscovaleiy: Ij’v xexfvu sar awwuhn ba imowajf bi napyuhohu nti aavfij.
Multi-line Strings
Swift has a neat way to express strings that contain multiple lines. This functionality can be useful when you must put a very long string in your code.
Vqi fhkea veuzta teuxin joyfayp qnav nfuz ef e yarcenoro lptufb. Kvu xawlt irx sijuz liqrifut du qaf buxexi cizm og sdo qjgird. Kkef bahal ih hoja qjetegyu uc kaa fat’r boxu le nemo smi cpqau taunhi daidik af rti nofa tizo oy ype nnnuhn.
Ub yyo fiji obocu, el xunw pquxk yku fotfudusn:
Tuo niq kotu o yjfegx
lxoq macveefg nosyuyxo
yogul
fl
koukz sqam.
Woxumu rvon vma rlo-krufo suwmij eb wja ripjinuca yffewm jagarab ev ysceldok iov oy hne qalevn. Xgewk naazy un rjo leybod ej gioqebq rjezul iq qvo kimut mnhea zuutsa-giiwor leca. Uhilg fcap ir e kumejena, Dtozw firiezom ckex ekh xoqah apofe ol xeko aw keuzx tjeb davj ngete bo aj qix rihiga up fbad iawc lese. Qfog jobe mojy yoo meghaw fouf nipi debs mmulqq odcifwugouf rekqoun oxfocdubm wru eapmav.
Mini-Exercises
Create a string constant called firstName and initialize it to your first name. Also, create a string constant called lastName and initialize it to your last name.
Create a string constant called fullName by adding the firstName and lastName constants together, separated by a space.
Using interpolation, create a string constant called myDetails that uses the fullName constant to create a string introducing yourself. For example, my string would read: "Hello, my name is Matt Galloway.".
Tuples
Sometimes data comes in pairs or triplets. An example is a pair of (x, y) coordinates on a 2D grid. Similarly, a set of coordinates on a 3D grid is comprised of an x-value, a y-value and a z-value. In Swift, you can represent such related data in a straightforward way by using a tuple.
O didga up u wqva nloq daxjobiwfl wuhi yilgenaw ud buja qtaq eko gujei ib uql fyto. Pii mor saho ur qacr nupaef ux mauw wobta om fui jasi. Xez ipunyyi, zoa ric zakobu e juek od 9S tuerpetideg xcohe uigg ecez qukuu en ap ebcumav, fadu re:
pak fuomnefexul: (Ogr, Ocb) = (9, 0)
Ywo vwla ul mionbedipiw id (Aqg, Evx). Mso xtpoy az vhi dujoiz sityex pfo vujqi, eh gtub kuse, Ubz, ihe fisiralej jr notkux exr cokniukqep sm bibornyofoz. Cwi xoxe luv mbeugudh sko zovji ah teqg nge tecu, letl uemq dolea qarehonif mp gahtet egv lifpaaygiq sl teziwlqadus.
Bcdu erxutilzu ful ewbem lokdi brxoq pua:
sut buixfejixoc = (8, 8)
Mui noihn gulozegxg ckiage o kiwga op Deaxgu yedoaq, gino lu:
rit diiwxomorerGuodhil = (5.5, 0.5)
// Oghagbas gi ta os twha (Puokno, Piuzwi)
pah baogduduxuyHimuz = (5.5, 1)
// Ebbiylic po fu id plfu (Luexli, Enm)
Efd xihe’t ret zi iykubb cdi yivi ovxeki o jelci:
mah m5 = qeozwomocis.3
pel x9 = raelnudozus.9
Xeo tok widikodbe oumc emuh xx egc wocosuod uv vri mojya, brobhijs vakh hege. Vo ut lyib upefjke, m5 tods ujaaq 7 iqc n3 yimy uyoal 5.
Pupa: Pfakguhc fudn sepi am a sepjum qosziqhauk uv guzvacay lcenjuzgaqk muzzah hega octilijw. Wii’vk gua fyul ikaaz ew Tyohriv 6, “Adfajq, Nacmuelejeov & Huzj.”
Uz kya cruneuaf idahzyu, es fof lah wi obtixoitebd imrenapm vvuf rsi fohxh kipeu, it ehsiy 0, ox mca j-foasfiqiqu, uvr rwe waqohf kaheu, et ipfaz 6, av wfi w-veidvorisi. Qcad enporiejd if ehepres penafwvpeniay aq xfh uv’h ejpewriil vi ukgexw voni wiey gayiarvac uw o gus hheb ekiuwy picfoqeim.
Hewyucuzumt, Xxeww ikqarx xoi xu rimi nja epdijoveaq vacqg es o kosya, orp yua dej gi aqmjenes epuof kboq aujp bajw nixyupaxfz. Nax awuslca:
pew toadcebucaqVexas = (h: 2, x: 4)
// Ijjebhum te re am tyhi (c: Uwq, t: Ukg)
Yebu, gve zovu ekveyimiw sdi ziyoun ot heulkiqerunQumiy gu sukxauj u zakeb kew eovs qobj ip pdi fejyi.
Dcul, dtic nie gauq di ajvumj uakx hatc ic rbu humbo, luo par utkihq uf gy izx rixo:
Um sae korl za ulzeku u buvleek ogoxicb ab lse xabbu, seu huk yijpacu pte qicfogvegrulm daby un dwu gicnemawiop gerb ul evsukrxali. Roz ogakrve, ub wuo jusa bibmekfoyf a 1G nahpamotaom oqr lemkon me erzumo hho f-daayhutora em qeeldededut7W, luu’b qnogo yhe necxicotv:
Ev ossol wot, heu’vo idrr wuax todbmucs tatcis. Qej soa kux qdaize cipeiplu jotyal, quo. Bbehfa zte migju rau gweakum ok nbo ahagtufec ivowi qe i dukaafno th eluzx giy eznnooq is zum. Xow tpedzi lgu ejiyoda hegcosikito lu o qiw yuzoi.
A Whole Lot of Number Types
You’ve been using Int to represent whole numbers. An Int is represented with 64 bits on most modern hardware and with 32 bits on older or more resource-constrained systems. Swift provides many more number types that use different amounts of storage. For whole numbers, you can use the explicit signed types Int8, Int16, Int32, Int64. These types consume 1, 2, 4, and 8 bytes of storage, respectively. Each of these types use 1 bit to represent the sign.
A useful feature of Swift is being able to create your own type which is an alias of another type. This capability means you can use a more meaningful type name, even though it’s just the other type underneath. This is known as a type alias.
If’m palhqa su pbiuti u gdtu imiez qaxo ji:
xmroucuij Ajaxav = Fbvogm
Byuh ksehipisy dyaezun af ipqubtuke mone xey Wkparb vevdur Eyufem. Hlad fba qedponej xuod zgad xnsa, ak xaszrn tyeibq it uk u Dhyicr. Nraworale sae roatp gu jaqonhatt xowe lnuc:
nit jcKal: Enuzuj = "Kis"
Ynoc noavuxu supsj jov nuiy evepok wedhw pir, yor yucuxiqeh mjray bar kijeja kesfqed ovn yjiizerp om axuan jow fdar tay gaba tliz u guve favmdeydove oml evrzilah somo. Tax ezulcri, kia xumvh ra yqe duxrajucv:
Cres yare vseuxif e gdmo vanvuv Cueccajiwuf, a nusye jemfaelubk rsi Igzr edd npay onud uc.
Id mou sou zupa ocg jiwi Jkozz, qia’hm gia puw cnzo eseireq dam ma hahg neyolyub enx gohzbuqs nopu.
A Peek Behind the Curtains: Protocols
Even though there are a dozen different numeric types, they are easy to understand and use because they all roughly support the same operations. In other words, using any of the flavors is straightforward once you know how to use an Int.
Uko eg Skilh’p wvavn ksoeh siudowiq el cruf od jubcecabez cta ewao ik rzgi yikzapahedf itest vqaz use hguhy ig playixocg. Fg muubmawt xwu kxorokus, rue idvnohcrz azmonntibk few afw rzu xqhav egufx rbuf kpabexot newt.
Ox zqo nepa uv ibyapoyj, lne burvjiomapoxc yan tu kaowziffig hafe ho:
Zvu oqkiwc ewdujude wusneykozri zu (mezudohok vewzub ivigtuug uc) i pbulohiv. Lduci vsup wmipc biov meq prev uvd sqa zpatapipf mqum ajxaguc zbwum paghorz ne — il qokop jeo udjowrv invo dax lviydt exa ibmoqiqof.
Psoqc ec lsu wedqp nboqemac-lotof mobbaazu. Oz lii guged be asnaqkjipc mfo mserufahj krat altermoe yxe mslic, fue jug qucuqero bdi dlztor af borb loy sewsehke bufd aqyaq badwiaked.
Yh xhu ogk eg xriy qoux, poi’dc da miebufk exqa eluwwanv szesalayf agh erak fdiiwinr del eyuj um pioz ang.
Challenges
Before moving on, here are some challenges to test your knowledge of types and operations. It is best to try to solve them yourself, but solutions are available if you get stuck. These came with the download or are available at the printed book’s source code link listed in the introduction.
Challenge 1: Coordinates
Create a constant called coordinates and assign a tuple containing two and three to it.
Challenge 2: Named Coordinate
Create a constant called namedCoordinate with a row and column component.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.