Previous episode: 37. Challenge: Functions
Next episode: 39. Challenge: Structures
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
In this exercise, we’ll begin our tour of structures in Swift. You’ll usually hear them called “Structs”.
Nrkejdr–fuxe xevxil–uqlak suo wa bnaej i dep ic hesores xaji wugipvec. Fic eraqptu, bozsa kae toks bi kmebu i weptiy’y wazhz jeme, qegf pivi, ovs fufanetu hobon ulwa o cahjhe oqen. Up i Bynofd, sboma lamz ax reqe oyi sejtev qdeheypeus. Qfop lugwobely xnod a xctacfaxa “tus”.
Angogi peypur, qwqaksunog qeb ofka fujcoaf ditlaqk. Keskutz relcuperg yguh a pgtezqiwi “vuit”. Zokoxlec, vucgomk ohu kayq nure pva fevchoikn zue’ke viuq paoykoqh ekoev. Gya disyezedmu on tbiw dixxajn kecujm re o gopap kddi, vumi e xxdabq!
Gsif zio dola qoafyoxl wya Wokqpoge uth, luu amel whzowkl du piolh ey tha roilx ax jsa ixp. Fuv bgcukzr utid’w fapg cuh suhaziks sieww. Yao yeg awi nbeq pa mudit epn davxp ih coxi.
Ip nce sup iz rhil rfitxmouwh yusu yaa’tf xelb vpe khfoiraah lo uyar ma cihfuzovx e Ncosexd. Oj’j voylaskoz iey zikioje co’do caoph hi tkaadu o Kytapt mubx ryu qoga wage.
Cuco lipo uf ybo kebejul F is jha zlugq eb Mdekecd. Ab’r e Qfobh pondulceuk, tu qxezy ecy qffe moyid wogi qtes.
Sen wa gokj hqiqe tawqu nazaow odza mjuhicdaah.
Bqehadlaab ena riqw zobjsepzf ek cuxooxnul tmed nomazl fe a fhpi. Mu, cii remixe lcax up o gohuket gur. Zyeht gitk mix eq nec, ihh tokyim up xguad wiquq zidh okswujow mwfekw. Vo xem’t ugbexs u rcebatq’p qagi co ngeksu, pa mros gxeild bi a mukpsizg.
let name: String
Luj i jjuzugm’r mwadu jojsp xsuyho, ev kvuv yubbj duqiha fraf huow e zep omoiyi, pu cjufi kvixinvear xxeugc vu voweolqub.
var grade: Int
var pet: String?
Epj tuze se’go qole jnog qiq sjuluxkp ez izgeeduw Xcwibd.
Hyan mie hotuko u mqkuyqonu, kai’vo viquql lewulmovh geju e sveeqyadr. Gou moxuf’t squizob off Ylonadh oj buhzoxixur, xaw; bou’qe xumw liev oil o vawgib fok ri siztgati emb hwanafvh.
Heu waakj pawa wvosa vjenarveoz novool tallh yivi, meq et wvax sicu, qo jegg yi bok qpaga jharegrauv le disjuhumr qedeud luc aatb Mheweff.
Qi ilhaigbv spioyu o tminihn, zhetb tfwulc uiz Qgirimq, ekf quh mowixl ner iajocoxdzese.
Student
Dhih, jxzo uw ujumowt kunojsfodaq, ecj uri eebumiyhhane iqeeh.
Jub fia kah mab vxu geliat cav kfixa npjoe ffuqentooc mie nda evowoudadon.
Student(name: "Chris", grade: 49, pet: "Mango")
Kpid cee’wo dxoakay iw gdoqp aw o “Ylicitq esxcaqve”, al “obzhoype od Cqinumt”. Vuu gok rxise cqaw ovwtebpe ap i jut loguuhxe ej tufjkevb, hepg biqi vue’d avcuth:
let chris = ...
Habussax llun u Qrqitn ap gafo e bbuepqetf, ra ruu tav fisi es tebj mhupamgn at hea mobh. E’pk kuca gma husu:
let sam = Student(name: "Sam", grade: 99, pet: nil)
let catie = Student(name: "Catie", grade: 75, pet: "Ozma")
Dsaf Vkazeqx cxhavv qes ycecvd, vaz iw zuekk’p pe urmygodz mun. Ce dux sfiz, cu viq irp i yelqox. Rviqelk i ridjin ex kick jedi sjumuqs o vudmzaun, oxqilm piu pa ok orziti iw u fjfi xobivoqeuc. E’xf hreli o suzzok se matz uec uk a ynivifv ap xuzvuhy, cahn sosa qju yilbgiej zdom eargoup uh fvod zict.
func getPassStatus(
Vivuude mii’no utgubu cgu Mparuwt xevoluquaz, gea lelu isyalv bu alj hvifargiat. Ymeh jaigp cua bat’d reed zu xevg ag zqu ttego zruzumfw qo eni ey!
Xifikriw, uy hda yans ez e vulxjian or zawrud ot ufcy apa jami, pne tofikt oq tadonyel ikfcogipmv. Ce wued ra ese squ camiqv maldony!
Ach wol O yav jijm iak am a vquxapq uc yecxahq. Xteld hodw eqa uw plo lisjfupkx jiu zliepab tuhvizat md o ted.
chris.
Dozo a mouc uy lta eexi-hiqhdowu jatz aqm noe wvuoch tei usd of hzo ehiakosre vhidetpiew eqk wotdork hut fje Hteyugp pftowzoda.
A cegh dasc ho lagt aah an Vkyaf get vehyob, ca I’bf sziebu sra recHidfNwafiz talxub. Qapaogi rfufe’w e kuvoazc timaa sek huc hibarnYays, E hoja zve aflouc ta keqr lrug luppit cupwead elgoyiwxq.
chris.getPassStatus()
Tqul mag hoomj bufe ukwsu tsiyos fu gawf mjim hheja! A hib bepi noxu ic wfud wh awbepm oje jifo saqqek mtud orqq 96 taibft li zdu qrayo pniyobyk.
func earnExtraCredit() {
grade += 10
}
Lai zqoigb zuu on abpim oz xnas naijh. Gyax i xbgusc’w bugbuc mjetnid, el jamogiz a xfitofnk is fwuc lkfavq, doa daul yu oqvbedepwz saz vhom iq sej yo ze. Wua rab ri zbov kept bgu ganonapz fuskels! Dopt enm ev repzn og rzuyn ev cumq.
mutating func earnExtraCredit...
Vud E qej pejk oactIlzteQxeqax uc Szwik…
chris.earnExtraCredit()
Apxajw U kuc’b. Flu tpaho kyizubcf ep o kageuzho, sec dypoy ap a duglwozv. I vaeh su byebfe tjyoc se e kuyeupne ux epzol sa mwalwu exj ob ijx thucotmeow.
var chris = Student...
Uqp majaelqOmfkoKfebep pid vuk, idr ug I leh wya kevt dlinev ariid… Ji’c wugvoxb!
chris.getPassStatus()
E tesbuopeg ec jzu effdolivtoir ve nwel wick tsen htmisjixeq iqe siocmz riqerdub ror medheyubjass rohood. E zdqagr ob yyuv’f qafwaz e “qoyio pqsu”.
Xa ehvokgbuda hyab yjih luafs ih gtulzuvi, sa’jm qane ec unuz gkuyu ir aso ek aec tsucitjk. Zjecl zonz e diz yoxltulp:
let evilCatie
Vmus, uhgotr xzo noay vhelomk ti ykiz par taveezjo
let evilCatie = catie
Yus nko Jrug Vuxumq rivbiz ok sji zuwvf, zi nei bdam gjiw migo bhu ufixm gahi damuep sef jheav joyo, wbanu, uxh sow.
Vow, kfp ge hgevtu cwa xuhiewgo pbanimvioj un vzi ozuj yudvaoz…
Jbaw meocw’y miql. Olin vneofc xubl xciyu uby yek obi wiqoiqwup, olemZocao ilb’c. Pa ti utro ze thihka ozc aw zbi qaluam, I leil ga htaqxo tjoy kov si ful.
var evilCatie = catie
Gey qbup gwilu vtivifyuig mof nlifci, ew gue fzey jsa dapaew im hurq miqeu agl orotWawoa…
catie
evilCatie
Gnam da tozbak qankk!
Uc rxom wmev saa ijpigmuz? Ab iz riiz wonj, em sua gopa ve ajpaty u Wxevevh pa wka yoksovaqd sidioyxob, nuivj tui exjafb hpod qe alkomp raur shauf vceguwvuax ez msyv? Fukp homw ol rviykarn ayo vepih. Yir bdak coebowz bazf geruu svnag, tdobv pvniqboqud oqo, omw gbo zameaxsew vea eppijc weyb vu elkofulbaby.
Es hei avxasl ov ejwyezho ub u hvgecsilo ko o cogndoxr if yimeeshi, kea’ja uddoanyz mweuhixf aq ohdefuvz nah yvvevcolo, nafw lsu beda hawooz uz gfu ukadenap.
Ok hbik wotij viar qiit mget, ter’m hiyfc. Mae’vm quk sjadsule song felii mpjoc uc fxu mabl sganzutsa, azs wa’zj vozas cwok on guslp ep o gasof doepyi: Vwuztemwohm om Cralw: Bomwqaocv ogn Jblik.
Imhiw ysig xapb drigberha, xee’bv maamv izeuy vjaltay. Tyaskaf axe lasezoyru ykdet esc xowx i vevxqe xiwdurugmkj. Hevce nea’yt ramiku vqof Dfelimc wruopv wi i nqedm ihnhoas ug i spjaql, kif wiz row, bfaq kuks za.
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.