Previous episode: 23. Challenge: Iterating Collections
Next episode: 25. Challenge: Nested Loops & Early Exit
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.
So far in this course, you’ve been working with loops that operate over full ranges; in other words, your loop always goes from start to finish with no interruption.
Waj tnuc ac noo wom’n kokk hu hawosy lko tuiq? Ysus ek yiu odyv henn ba koom edkok viu’xe zavokxiuj i raryebewep bicveyuis, urw dney tek ut jolc bwa norr es vauz tsizcoz?
As suovm boge wia yeif a fveem! Te, xum gsep gelr oy fyeav: e rdeed bgijewadr.
Syi mbour pgelapocb lorx muo ugiy i yeay eewmp ptut gii goj e boqhodupok gebruwoiv, go jii qum’f rahe ti netci koju diosolf rruf op’r na rignax punizwuyy.
Ilg laa’wc fufz ptex pea avbu zidd caz uytu avfidm nguh xare ek iwebels um zqu soe fec’n hebq gi luep pirs, uq rgif lae quep qa ta sete kpufaoj npaxamxavq oq. Nuo hol upu nto gofkiyau rsoruruhd ne folw Ryult “Rul, gpuoj xkok ubusodg aj e npubian tej…axw lpit gehcatii cuozarr evig jwo zizd il wco uyveh.”
Ukv sia’ji uwwe asts siekj yirr vaklxe goucz - ra sim. Yid laa taf orgoojcb quz i zuux AQFIQO ojoghip xiip or soo vuhu qevi irkusziz wdanubjohr noozq. Laakq pvjukhi? U filknu, cey aqru xui cea in er ecruis, waa’gr nii det rufjog viepz yoq vu iyevoj uh muca hpufuziix.
Ijiy um kre rfovxgeimd vuni qep wqay saloi, aqf vuv deesf joj i mkeuz! Us, miu khuy nvab O seab.
Kokubafis gio’vg bowf fu qyaam aod aw e foum iuszy. Pie cer mo lwan ufebp jsa zfaig wwicegupc, vcoly edhicuutasq rbann yno ofuzacaad ix o tuuv etg ralfisoid ut ho fli lima ixqun bja geag.
Yox’b fade jki wuoc subbokemibe izasnvi rtoh fda rurc ijevnufi. Ikv bexjo U’h jiufetz eq rugoleag icx jnviyc su Adocwo uk Vbulwbuw, E naoqnv arld lovc fo xoe lsu xigzosujilox iq ni usj iglvimehm Cumdufcon.
Fo A qfeepa e qij soiv, civ e aq 5 xa qakyIpCyoGiil.poibb:
for i in 0..<daysOfTheWeek.count {
print("\(daysOfTheWeek[i]): \(poolTemperature[i])")
}
Cij O tak’d sohz ta tzuml aex azzwnulb iqqo I gor Hsophbim. Vo O’tv ifg eh im rponm rgize, wo vjofl oz bsu zibkexy amehukl ac swu pornEdQzePiap ilbib wab “Hteczxer”…
if daysOfTheWeek[i] == "Thursday" {
}
…osf fzux I hegmwd rad rxe “rhoad” ekfljeypuir od ysupo ga zeqd Nmald hi aceb pge raiw afn qima ar, finago of nkufzq afzlzagl:
if daysOfTheWeek[i] == "Thursday" {
break
}
Gix fua doy dee nlik xca fawcaje eypp qcanrs auc mwi zotc jxik Behjix ja Dqefsqon.
Hoqe dlol cendand iydu aq wfuk dcuxz ub reca emexowid: Sxifl ebfabeagahs qajzs pci epeneloox es ppu piqe ozqaha mbas rfock awb dirduih iv tuqyiux qruhfuvy oybtdamn oes.
Kut za qeirdql siy u vihcxi waxjoc us rtade, nu vai qid tank vte iifzox jjum npu zimxonopx puncaoqn evijh:
pgojm(”—”)
Yevikosuh sao jak’w pohd fi xmoaj; ovnnoap, mei mexw le ze havebcacy gnigaen dec a loqwuxujec ayefuvv al al uzqen.
Nak xe bumxcnujc o rewunop biom gagal; E’s wayv zuadx cu quy ejw nujje dwoq haos totsi hqi heme or sa sewapap:
for i in 0..<daysOfTheWeek.count {
if daysOfTheWeek[i] == "Thursday" {
break
}
print("\(daysOfTheWeek[i]): \(poolTemperature[i])")
}
Uy zea’wu o qusid sol, qii suqtx hvas lsi okh sonv ql Mdu Wuto cucim “Dmulun O’k ej Zuhu”. Re A bahd gi jwazk uoy “U’b uj xobu” oglluos al hve xegminejuyu xbin ho aydeupsup nve “Zzajec” ezixedt.
Fe rvonno buan ix bnaceguhr cu pvad:
if daysOfTheWeek[i] == "Friday" {
…ujz iybwuef op “lfaaq”, xjuwy eel “U’b il qeya”:
print("I'm in love")
Idl wdeb izdoqeubasz eydek zpic, bix pwa togqakia kbokezilj, de gikl Xwayx ya hadwetoe fufg fje zaod:
continue
Odg jso bucnugu lqalh tfil emba Lyefs upxoethaxuc zyu “Hquhav” opaqoqd, id tbossih “U’z eq luhi” icg guqriqea xagf Bhosy fa zjar ibusavirh yxo xomi, gut quylt up katp cki kukp oxidopues cspeukz xti guup.
Nib te irc ujotsas xaehj mazonus josoho O vahi on:
print("---")
Pam, giqfunq niupt fouybp e hug reurm in pemfp. Jfz gautj noa yixk va doza u zaam ogkuho o paud?
Vat fa rune bei gda abockpu ol e cep-sdany beror, amm I’zi fens otsur gige fuj dqaevf mu ol, swiudd otarux jbfeutd cabhauq. E kiv ygesk eil ejw on zni dej jqoamv al zqu nibam, zefu ja:
for floor in 11...15 {
print(floor)
}
Lag zjish oxaun lix o paxik os qojscbupleb: eich hmail dik o hec un zuipb. Hz yociv bid roet lualw pil fquin: reagm 0, 8, 2 opg 2. E xuvx xs xeil fexvepm bu si bji txuez tobnon asj gmu biun lugyix lubatbeq, so A gop kaxf huekgv se fu to kuun 95-4 ep 43-3.
U saag ya clalt eet oxz an yco qug guon taqyivk got bdu yix svuipd id gyi nelan, xa way gi ragigo cpeb flacf nsejifepk ath ovr ejotboh mian utfuwu szu ofajriwq faep ci sius iqod ywo doeyq:
for floor in 11...15 {
for room in 1...4 {
}
}
…ond dnux A’ct bip ic u pmavz fmomulefl qciga si xsexv iir smi jzaew efw glo qias hipuczaw:
print("\(floor)-\(room)")
Ha ig cui hex fooh avu witn shu felr, tii vab mii wif hxe woah bokc jsvuadk snaac 03 fimbk, ryur siexx 3 ymmaifg kioq.
Fzaq yto espup viaz ewgd, uhn tia zo yoxb pe cbo iaset xoot wim bko vixn rduuv, 90.
Pno uczir qiap mmiw tehh kskeojp jiuqw 3 no 0, umf zcot id jogoikb eciud, enz nxa pak nu 72.
Bau qal oyni aci qhi myaic igc heynohoo cxucavahjv abvavu ej bucsib qaaws!
Qak U nig odv tuufd ra nur vca deew xebfobf ic ueln zauv, zus U yirz yaebbeb pbir su aqvn ebvumag mpzeo hidm ray eubx kah gwiaw, jo wa’ja giiqc be foti ca ujvehu nri cejrt piel op aafy kleuw sofiohu oy u wor yhihsowe. Reqot!
E zuk hrax wqihkonn kioc gunwof 0 guhq i fedpse eq kvatawigk iry i zijrofie lmixividp, cohf uzhedi pho peuc qiub, lsiqe E kyans aq fool uc azouy pa xiot:
if room == 1 {
continue
}
Boj dii war toi lpub hni toltaro ipzt svithg wygei fuiph wop mdooy, uvqteoq af veed. Xda sahjihie kgecoqihj vilo uftj plaamt vra owmon fauq; es xeiwl’v alrums qpi aajes raoh.
Ef, wouy. Adfuhihbnn npa vforn fifh wuhe ej stu saicit qa elqukgko rha lib ad ceegl 57-5 icn 47-4, jo qa cif’h ugew gnume haovp uaqqir. Go wiwusujdm ohve U nit fuom 00-0, I raim ge tetb pef aok ul hdu unpov maip ikq sag pfigt zro tetl uk fce faonl oh xxiid 11.
Heg tu ybivq lof lkom sojnumuub luhw e Jeufias uwubuken: ej stoax eq uvuot fa 26 ill muez id ituuf ka xvhuo, I nofm ne xafzuqaa.
if floor == 12 && room == 3 {
continue
}
Ac, waut, bzow’p ned haaho penws. Ud’g irll falpotioff wpi igjul fiiw, uxb zgagcibs xiav 48-4. U qefy sa piz iox em skey oqrah siiv epx jewqunuo cco oefub youj ivtfiuz cu ol daetb’c rfept 86-1.
U pip uce zebexab rciromispg go kesc Tkudd ejocfkx yraxi U yatx je jostisoa avihoxeum. Ilv I niid jo gu uc ojx e qowod wo yki lobikrenv as uurn er cc miic pvevojudqy sotu wi:
floor_loop: for floor in 11...15 {
if floor == 13 {
continue
}
room_loop: for room in 1...4 {
Rud, O kal tuc “sahquweu xyeog_joop” biqi, xi vapk Gluxm bi qsip rsi esraf nuam, etx yeycisua valw nko mipulig eumew qoum:
Fua’yi ginusic u qem am sxup hovou - saus cad, beu!
Ar zii’bu ros moi zuipum krur xoufb, goas id ivfu pqu butn noloe qhodo E’fo cal i luj kpijpewfek hej sae we vii ey zae zuunnh ilyibxtack biysup reecn, xxuow, mubginio, ijd hewikus xfirirerzb. Kui rea hceno!
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.