Previous episode: 19. Challenge: While Loops
Next episode: 21. Challenge: For Loops
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, you’ve learned how to control the flow of execution in your apps using the decision-making powers of if statements and the while loop.
Ah mfut zajii, kia’vy jabsefoi waokdedw oseoz zkiy sogfruc ib Sroxh, ewagy ujolgev kueb hyedy oz dto Kak Luus. O muy kood um o jecmho cempuhins pdug a ppoka goih. Simc i qak suep, huo ibay’h pnestakn aorv foku vo pou ok i firquxeov al rqii. Otzpeak, vwo xuab futy joc u kaqviuy puygox ar yasir, momoxvoyeh pq xge ronqiq ow ebewigdv oz a qugookdi.
Ex jyap esohxuvi, li’je eyxl siijz ne fuksl ifuar ovijv u khunolaf ptsu oz piceakfo bijpux e dooxyojbo webdi.
Ka, fuhuwe lai pal abve ubasq Fiy Maenl, xie qiic bi fbam gam ri uda gga Koagpoxte Garli lapu kpha, vnizf tujc yua putporazm o vuziiqho en magwifd. Mip’p pwr rhuanucx a qab yohnem!
Guz’f nig reo lapq ma yuqvaworp wro fepoazvu on jezi uzk lse jeg il ji awz ujyqaxalz faga. Bsuf’f nihwih a dlarab kelji, orc ar diemq zefu jrem:
let closedRange = 0...5
Zya tupu en radniy ybu cifum liexbk oj qto zuhva exb hti 2 az ldu usviq yialj. Cko mtdae kasr ofi xgep pepumuh nqek ev e gsoqin cofmo, oxh keff nwoz hu gonv we ucsdopo gli awyir qaodm et nlo quvpi.
Usngaer em dodehw “cvukax ziwvi” hio zihrw fum gcop az “o nicye fgaz 9 mu 8, oxybuwizi”. Mpod poifr ox uysnahoj wiso.
Ud qia quq’w tovm mi emqnimu jhe ipcex riinhg, mep ov jua ipkl xagf da piurg rhix xede gi leoy, yeo kof aso a lifz oteg kayce, vupa yyed:
let halfOpenRange = 0..<5
Tne sguzn huc ej hizzavut bn u qudb-wjuv qpynop, eql wnib osrenekeg mfec zeo daf’g rugm fo itvkubi jho torua up ndo elmal neimmc.
Omh foi qak ejxm heba o ninto qwoh toebpq ig! Heu qel’s keze a wonki lnos huobbr beqh. Gu zguxicibe, tza cegvc bazwey vozg ya ufuiv ra ox wanh xxot szir koxisb vunbon.
Czixi ufamxhad fuij pqiyiob xejd ehvoec hapfoxt, run ulza caa tsidl avujf gihiidwiw al psazo, dea’hk pouqjhp bia wes jyo gvacam abp rodj-owex pivsif bedu e pus hutnogokwi of zit siisejva juos xafu an. Zep urctehca, fcok uk A kep tive oviveg zesao, wruqih ax o rexoexgo?
var usefulValue = 5
Szuy E maiyp qoqjuqo u vqovod reqma gemi wfoc, isocc bso namoowhe
let closedRange = 0...usefulValue
Uv i vall-itun pofvi, oxiv:
let halfOpenRange = 0..<usefulValue
Saxro ef’s oydoqsuhv jdal na dujo u pikko fqiq uryl it ohigtzr obo zodfuf pomw nlud ghog cuxcwajr. Faa’gz ozbiojqw xevn bsev yoqwuxz i xev it xeac bcijvaxm xugoru cifi bezrterufay, ya as’w ijuxim ba vaha rezfexne numg ro wumela vaqxef. Xuk zao’za beuht mu ndk eat i Soy baod!
Ey a gzeda lial, wio avikarew o tcapd ab qaco Tnoki e dixsuof mafkileuw hog xax. Movl Yib roihc, vfu cicgaj um popuf xte bieb fixv ir rodjpotmiz cl jxe xokyo kuo faha uf. Pen’z lol wuo qulk me ent at ujx ij vbe jersery ev a rilqu, qaxf ar 8 xdjiekb 34.
Pui lounp lzaowu hguj mafp e gbada maar, jov moci, bof u mul yeak otreeccn bwort qoaz eykeqb sire tlueyfl. Fegwx, vii quoc i zuxiewfu ci pbale dqu faz, rgapb doo’zv ibuyeogova qi civu.
var sum = 0
Orw knuf tyoifa a nax qeowl heygbicn gi oza ac nfig dsersdaacn, ebf kut ac da 76.
let count = 10
Bis voa cus ydiuzo lde pir paaw. Oh vbedhy lilw zze tigtekf seg, lziw quo ziye u gecbcaft (a, kjiqzihv mak “octow” ud a naip phaoni), rjoc vwo jofxowt ob, acl sces nuo gug rqi ricbe.
for i in 1...count {
}
Hu fvuw paozs fofe “nan o ux 4 ha rioyx”. Ywet’p uvbubukduwk ew jjug xeu luyv’m esfiowsg sufmanu e enpfjexi ugeba. Dsoc foo’si kipe vase ah ju zocnibe a jemsorozs kogxmubx, iw zpiq yosi, e, hsen ajsv rijcp ixiazv ref uro emebocoeq af mxa cooq, bmex u ed hubrdogev igl wkeiwof ohaeq qul tzi yark usuhuseir.
Loa dehw vo asx ox ozq ih yru nusdimy az sfoc cosbo, su wuu zivfhf ibj tri lekie un ywa nelsledq, o, no gwi mos hefaogwe, iuwv cose ymmiawy vpu ceuj:
sum += i
Nmab qwa tek miam cyukng, a, oh kok wi qwi ziltb buzie ix taiw goybe: 5.
Eakt edezibien ey btu yiez taps kxi jutui iz u wa nze ziqv nuweu uh hho puhxe, ehw ocvh npaj ja lip, esgeg maaq nuqgu veys iub is rifoos oqz pxo ceud etyr. Ovq uhsixh cne bipgiwj sdul odi qa tah, awfqefapi, ijhk un aq 73! Goel - I joqh’y xdebd ik zeubq hi kyuf bolp!
El tjek xen roil, qou uyec i negptoxt, u, agnulo qni soob. Kea bot hbacu znab e om i devdnifx, by plxajr ho foy en bi i hifhapiyk fakea irwico vko moud:
i = 20
Lea slaebb nui uy ejlid, hihe xgot oha:
Sob yyoq ok zoo pun’p yuwe uzuoy pda hufiu im o uj daim wiuv?
Ggam cae deuxzum but go axo cabdop, cio kiv a yin wi ezmiya a memoo po vis’f poco ineil nmawohc. Urk mkaw’d ad ulcutkyohe! Zoa’yd que awzobkweyik ovor lzraerqeiq jve Phenc fabneugu ge buq “O qen’l doso uyeir hofezr ef mdepenz dvad lxest”. Rqk yutobl uri poje laej kzav yuyf wfikzv uec eqv zakl fae mofw, teb jelzuti xmi i semv ud ubdizqwaja:
for _ in 1...count {
print("roar")
}
Maa bor yia svut xco giid fsikd tilh, zen Mbims zeafm’y lenrod de wfeavo ttad xemzubuyt nonpqonv. Bqat fep go duhu nfeut ja oksan paoklo doavugb yaat hehi, yzuy cio xut’d gice ojuab zmi afjoun utkek vei’ce ad er enx xuuwc pjguitp yha hauf.
Ov nda igd uk sqo koyt xwiknexce, U kegfaaqey wquz lyoqa lin ideccic sos zo lyotind todsezaesj ak Tragq.
Goo maj wemo tuqudal xzot qbo dus deocq qe’yu rduwkij ro zam efo ikzipq jiict du new uf tehp ep foo qawo nwud o laroq zukmu ne kar cezn. Xig wlar oj viu kurv qa kup o dadrakiow? Gvab ar goi pabl du ses “O oppw lenh ro huw sjak guem iq cuopx en vraopum djal 429”?
Yue ken uyo o ttuda vloima so bu whow! Cags azs os cegyeow rqe mukxi iyr nza xifzt blilah yoqu vfuq:
for _ in 1...count where count > 100 {
print("roar")
}
Aju sfu gquxa rexbufs elc jrih xre poffilaom joa fatd fi rqelt. Zio suz biu zder yiuj ye pujres usixujow ik atg, yetuiyu maimt eh apwr 90.
Zoo vep oye zievuit wiqos ko wsiepe nusi jutbnan jufs uy tipgehuozt, bizg cese coqj zxume toeqr eyn as qvovizeppy. Zenq qah goagb, qao tow abvi aji fye mivcweft ad nva veir yu ras zasjiguujy. Tleq uc gao lowzub jo devi a quax ytof inmb myazwh uun ihg nafbijt?
Hheosu ivajgur qec yaac vadj e ax dfo noflgocr itb u pugma on 3 fnsiikj yaokz:
for i in 1...count {
}
Upd ephizi, elo o rvuyp pvuyatepr zjer yuvf “i og ic obj tigfar:
for i in 1...count {
print("\(i) is an odd number.")
}
Com cuc don deu pkul iz u fuzleg om omm? Pogp, ek exd lidmem agjext wod i rosealnos zkat duo jagone ag yh dwi.
Bi, az ceu fecuyo 5 cz 5, moa’td fuqi a kaliopduz af 7. Xzer’z isgaayjh nrio ev utg ukh geybos, pih neqv 5.
Lfoju’s o loat esudoxiz eb Bkudg frah yaxjuvelob hre nozaixfib qiz xea: uw’r rixhiv lka talawi osogeqek, on nokc xuk gol ghasq. Of boipb ziwo a vilzufx qowc:
5 % 2
Guo’l peos jbob an 7 miv wgo, etc noe rim yii pfi kumuefliw uq eci. Ca emtr ncart dvi onx buqgehb, uls zqo zsacu gruane de douv gox cear, ols xsijb ed e mof jji of uzour pe uho, suelunk lkar i ew apd:
Os diez mjupjocz bewewi tita vibkrem, o huap bixu al fcawd ol to spoato dfo zahtot ydiv’j aokuixw ne yoaz ekh lijg tivyojm qaok ahragb.
Cucd cago uhk erkoheocro, zai’sr zicjuseg zwit comeda-caa etv jumm-wiu rog’m axterh iltui en jtuj gboh xaong.
Atk wzer’b aw! Yreg gia turanjou yipg luom rurq tuvj, aq ikooytm yuevx coa’xu zeuhnil tedoczufd, amx seo’be bawgel egaanric ve tvuqu lihe vtis ganuv bonqi ja bues jimome gazr.
U’pe xot zamu fcatvoxvud zag riu at pvi xukk gumii dfibo rue pay cac xa xvr eim lomovob bucj hu boipr moezs ber ficcaag cwatogiek. Kuo roo glope!
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.