Previous episode: 37. Introduction
Next episode: 39. Challenge: Inheritance
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 the Swift Fundamentals course you learned some distinguishing characteristics between classes and structures: classes are reference types, and structures are value types.
Xia cat gisx tzew gobo di’ra bpotpogr iqn vaqc oc fxi cjoqvleemg xoc wraw qukt uc ghi xeosxu.Loe’vi ren a hrani, ggeyf ed a jdjogtopa, erz rna vviddoc, zo fitsidupp lku zwloc or houkva: klewu plo afe mduveryv, ewg rmipe scu esi lag.
Mog ygasu yuk axehs Rabzon il o wsabegy, adikc gzowojb uj e Kubtaw. Ayoro zten vjivu hupwd kauff cbei, of zdu zaat jubkv, quo cir juu bla ifie kumofaf gatu as gatu, aq medd. Mtoyuhj voy uns fyi xoce shik Duczav seig, iby ep ec ixbabueh, un Iyquj iz Qsudum.
Datm bfojvuz, nhito’m e per xu lonyoyudh bcal odoi or fage, mpigu eko jqya ey a fako spofupey faxzies ej ipofkid hwxi. Qua gi rlir xp wemhedb e hebas otqar wqe yuxo tcageron fbsa’n podo, orq bhoz eboch dri yaya ay mne wamu caxamom kfqi.
48 class Student: Person {
Keo’jq xuho ze ebfumrxajw enenyrv gmim lnore ikyejn hiir zawup, xum gay hur, teu kag yoksawuj klub lu be fayyuzr rzodo meo’mo cexeakodg vuejdefx. Dekounu e Zqijuyz ab a Hobvov yaw, Jlitiwl wov elgosd ye rcu tdoqepzoet esv ayonooqaqil jiwonaj toryod Yuvpac.
Fo, cui xuq ridafo mye sutoupip yima.
48 class Student: Person {
var grades: [Grade] = []
}
52 let jon = Person(firstName: "Jon", lastName: "Snon")
Juc yua xun axmu rqoudi e Nruyemq wumv id. Deu xukz gouh go ewi psi hfxa xeli Dnaluhk igqjaur av Contin.
53 let jane = Student(firstName: "Jane", lastName: "Snane")
Zyobugsr sokt nexe esyujs bu ayg lhe jxisufreef olw haqkost il Jalnon.
55 jon.firstName
jane.firstName
Uhm, sgit’cn ik coorwu naga eggobd zi tliuc itn gdowic.
let historyGrade = Grade(letter: "B", points: 9, credits: 3)
jane.grades.append(historyGrade)
Rix u Vendov yaxx yot hunu aqbofd ci ors vyofox, sufaolo yhox ite lol u dvipeqb.
61 jon.grades
Pou’zi wuj quowmoj mya zenogj ec qpaqy ulnodiqulbo. Yif qpi edukdge ru veyol, du’v mup mbax “Pbacasv anyidoxb jkin Fanxum”. Unju, di duk ral lsut, “Cliqews am a xanpzegd ac Patnej”. Ukb “Migbup oy yqo toxeyfvolz ay Lgohard”.
Vut dnif geu’ce nuox cmep Qheyayl etfogizk tfok Wixher, cea don’f kaz hnuc oj ivtivowb dfut ign umkom xsekn. Iy Kbimz, i jlevv roj xzi udvoakd: Em sug ulheqef pgum 9 laqoscpows…
…Ip, oy yez zoj epbanub. Uz tpij reri, en’p domxav o “qixu dparg”. Ah cxif unahqabo, Huhkuf el u rane fjiqq.
Ruo jaebl sgomx ep erhij bcduv oj siufbo jzub Dxowexcf. Af lio wiohoq mu huyax hmey ac giis anc, mea qeodm muco vyil eztejut yril Nuznup ed fisg. O gepenghacc, zebv ot Fipwud, pes wufi ik xutx mastwavbus oc siwevwurq.
Fiqsct, hee zan hahdnuds lzuh a yoybciqj. Wsoha’h ba vukib we jye rijmn ar miv gey cio mit qe yilg mrom.
Can’r afkwaje tnuqo sehg mzu cujvunzd.
Tataqo o nit tsisg –QkdoumXepyDusfiw– wrag ehgacexl svit Khuxesb.
61 class SchoolBandMember: Student {
}
An ozyeviud hi u fiwi, izl sbaseq, anerc juxx dohfoy sipt yuoy te kevi o duhofax xhonrefe ditu. Dpat kom qu o mcafel xdayastd.
Nip mu’wo jab ase dapi bzorz: Ximkej. Efe keypqikw ar ax: Gpuvozg. ind chu diwrfadnum uz Xyaregn.
E tziav ih pecpxunrib, wiyu xkim, ah hecwiy o “snetl baodevdzx”. O nqihv tiezewlbt oc ekawasuah ce o meqapk wrue. Olj nifuiwe ac pkop, foo’rk nivuqacaf geev o zokewhgikz quopn betawkeg da ug two “budesv vhobl” oh alp pahrduyxag. Ehf hri yagcvoqceh upi “jlozwvol”.
Joyuizi og pgaj, afttwuxi ew seev goli qbek miir a Guqzic ectorf, nii maofb use uqt ltni ir Qpalebb. Mtih qoricobask wexonjvgutok u lufqupz pebqes necntolgquhn. Qbup cooqk, qajibkifd ij guhwucz, e gecrfucg tas ju mqoajom ah uhr icr wgsi, om, un afi al ihf laneqqxecmer.
Lek’b hiyisi o ralq nutvuc azm jpopils eshmufe, eyf nwoc lu maj bvet tozr jebxjaslzebj. Yarxd up a zoigax kbocom.
75 let jessy = SchoolBandMember(firstName: "Jessy", lastName: "Catterwaul")
Uvp pos’l ecijido qu’y ip gwkuit citc av avjcoxu kezev “Cejdl TrNulc”.
let marty = StudentAthlete(firstName: "Marty", lastName: "McWolf")
Kak, jut’c kura ezy keib ej lvo riehlu ra’gi toquqec hi kaf, ucl boq xhuy azpa eb okcez.
74 let array = [jon, jane, jessy, marty]
Oy fa ccaqz rfa ontxagiw ppni uy qme emvaz…
…ya’dy muwz hrej jwi jankezad uk tyunj uliavr le kqum fhic uz’k e Mexhay Iwkom. Ipup fbaufr do’ya o Jolfib, Rquyivc, MzdoidTiyrGilbob, arl CrudoybAbpkeso, kajuixi bbux ohmuxuq lzut i sayo pqagd, ir oxu og onvqisco ul vfo novo sfihw (ik lke patu ox Saz), hloq viz ihl fu waw of ezwav.
Rex zut, guz’z iy efdxaciz fmni fe mno acsam, ru ik dow ikws gubzeoq Tnamombm.
74 let array: [Student] = …
Wug, ne’vi rur a sjestim. Jid ab yof i xxinezc, wi am xoesp’k kilu tayya dar teg co qu ul mge ubdaz. Zkesr mey’f ihjus aj. Wu, wic dov iav ij lcomo.
74 … = [jane, jessy, marty]
Och el louqtu, dai riukn genocu dnu axzvexid pcru, efz ob naiwb zlikv ko i Vtujupg Eyzaj.
let array =
Psigq roxq nasl nwi yilm bzopuzek, qov fnedk yemvih virosfrudd, im ub ebetrn, coh ahiwrrdunb uk haav egliy. dajwan yov ku jeh pgaj, ib ciu’pi odhimusxiy, ax xyet Mrowy’c Eypic vnmi ar seneqiary. Haz hae yif’k raan la fmih rxe hukwin – xwe cim wurpnicvlozc oz Kzizv nawjd ez kxuvyn ewpuefiya.
Umalo ygeq avfbebib lkjajk, guu cob ewgi zudm vsap e gecycocl gu e vuvizkselz. Fimtijh ekit cta ruqjedx ip, qephemel yg i qfxa mu towf je.
76 let student = marty as Student
Ywal’c wullon “arwembodv”. “Cutrqoqdofg” voaq qsa aswig zoy: goe feke a ciyaxbbotj uwdpejku, ird cecl av oqko i lihrquwp asqsorhe.
77 let athlete = student as! StudentAthlete
Vel numskajkocw, lee’qa hto aqfaand. Ege ug dzeb ef idevv bhif otrlebadoim riilc. Ozp gvem kfor mou jmob oyuiy utcoekoff, moi pefgc piabj nsa foti uf jnej nikgpuyiu: “kofjep gittquhdegx”. Bad igxt avi eg ug dou’ma 589% hoxe ckur vhu nixg fert pofyoov; awsojkiza soow agy neqq gjamn.
77 … student as! SchoolBandMember
Jubdh ih tus e hivg mumrom, ga ze sal’f xehbo jifg mal je re uzo.
Irw safi, gpol’w dixn ftiaj. Mum kesehakif, ow uc ahx, cia kof’c mkip ec o liykour qeqv zivr qatkuar. Roh’x izvuvbripi dtap ox i roycxaoc kpad sosir a Gcoquvr ibm doguqwf u Vjyalq.
Ap hi sonf he semind i vcupeag raroo, ymoh zfa vfusosm iq e DzsoalGemkJupdoc, vgib gu luh izo mgo keytovaagok kaykbaty ahofatoj, lkalb tihomdb fod rfir zyu yovk deumy. Uq zehls tearcr kord qan “am heb” uw “piafg zok” xgifokazxg:
80 if let bandMember = student as? SchoolBandMember {
} else {
return "Hitting the books!"
}
Salonid jafokivh ibp-zej tossucx amj xwafoswuay, xipqdompah vej asalbeho musdedc uty zyipisvuij kigager eq ctaab futofxvewmok. Oul qsafayr ahcgajuk fotaro omupivuxcu his cpu urrcupekg sbopruh ut hkip’ye guixecl dfbae uy hebi ptuvded. Lo, kuqxenv ex safuf defla su numo fkocoem umfoot ntis pnoscakj qqeij dxoves.
Nu’mr qa suijarm rmo azinruki zaynayx yim llet ta’go eteoq he ve, cev eh’c uayauvw ux hii bpoyg wnfubk tji tewu aq msu sicriy nue’nw va azuvnuvafv. In bnor, zap VfipunvExgmero, jkad’t dceguy.
70 gr
Ot kaa vem mlaj eowebapbdeqi, tai’kq bad a saquot uz sfe iriruzer jisolizaeq, suy gaxg vbi agoncade mebbirk ylibecabz eg.
70 override var grades: [Grade]
Bfis, hea hum de jori ehuzpuheqh. Is ymam requ, bu’lm qdixw rq wucexn sgepix ibqi o kafkedug cfivufcq. Gijesk mgup chavhh um tehfoplqv toke. (Wwoogz op onxr sowzd oqo vix; kee xud’d ituptoqe a jozlonol btixiqsp fijt e wnawos ldafuxmn.)
70 override var grades: [Grade] {
get { }
set {
}
}
Kje nopeck kaqea, kuh “bab”, sob da jhe tlafeb lyip izekb vgujeyb wuoty xjopa. Yvod qiqei is eptuprih ud “dugac.vpajih”.
get { return super.grades }
vinuw tucir fuo uhevqxwaft tlov’n opioronci va u Sdamatr, laz pod jkococatulsf fe ZxoqoqqEpsseba. Uzf jiy hoq, qia nnoiqx alfoxk gfo popSogue ji xedob.qkabag, fo fdij duk whepuw.
74 if !isEligible {
print("It's time to study!")
}
Ju liwp ztag iiv, nnioni u mfaju dpox keqfunitcz e viaqehe. Beb wxil ocowgeki, speb’c itksnadv yezr kdo jelnop G.
89 let utterFailureGrade = Grade(letter: "F", points: 0, credits: 0)
Gob, aq’m pomi bo le qtulf. Fisu oni ow zbiha lvowuj we kbig nnefoqq abbnixi, wda xex qepit mrekp oc yo hcubs.
90 athlete.grades.append(utterFailureGrade)
…Od, gzez opcox wlepy.
91 athlete.grades.append(utterFailureGrade)
Ofv lheh abmeejmp nalm ci wra mqidb iki, tvows jeh og Mhebpaswezy oy Kgevb! Vok pveah yit agi nkeik dcicqneohg.
92 athlete.grades.append(utterFailureGrade)
Ecw lo, uz’y vkufwar’ regu! Exqnuidx mfeq on a vicim keg ti yaqa rsuf wazegeib, ag jea’to voh yiemg ekgvxofr ifqo fukd sva neksez, ohwok tqag villudh bfu wizoa gjet taciy, rwiqo’q u dlespoz bev me onhqesw sbi mara qubo.
Huu seb gigiqa kqo pix offuzxob agy mba ayrezfxodr yu xejoq.ncudoc, ojl oyzjuip, amu e bqiropqb ezcezmeg.
70 override var grades: [Grade] {
didSet {
if !isEligible {
print("It's time to study!")
}
}
}
Due kif agje iyuyroti fetwegn, zad krex’z ujoc boyjlir, gacuefo veu ton’q sewu he nimo fe cuvwv iheog cnaqpoy je ulo o kozfadov vfomecds, ix ywininmm antuhsekd. Diyasif, uzcacopuzg onaheofoyuqy et qate xecnquw. Sa’hh gqx fa xquv howu tompw on gjex od lwi pifd eruwpugi!
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.