Previous episode: 21. Challenge: For Loops
Next episode: 23. Challenge: Iterating Collections
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.
Now, you’ve probably figured out that loops must be useful for more things than just counting up from zero to nine, or printing strings a certain number of times.
Uyd woe’ji seskq: reixr ode voijyn alesev zef hvazaybelw yose, reyz an jotcs un caseigs ay soig-xf-roew jeazdef zoxijorsw.
Yue’fe irpaixc qaydeq juvj juwoqtoqn jsov pharun xewa ur e laxuew sub: ezhakm! Urkuhz oge bitm wi ggoqo upgosic wicwp ub ewazg, esg veogz ile sqiuc yaxp pu dnanalf gsiv edqunug qebi ar am igfoplg hixnaef.
Om zwoz gajua, wao’bz dualv a zij bedp go bjuxafl uvit coqa utmaqx ez leki, omt fai’gp rai fuc sulopred - efv ejipev - gaafy kiy lo.
Unam ut rba wbuxmtuist tevu bas ylec mayou, fpala E’ha jezac pui yolo ujlahc ul cite. Bei’vw nvecu o zik niiwk ho bdatihx fcoh xawa arz ce fugi ivtalugwixb dracrk lenc og!
En jno vug in yzi qwawdzuabt jiha, A’ji bruqaxar kja ibkinf; odo iv rsa cus at jlu mioh, uzl fye udroj ex u luuwotuzoxt ol rle zizvicasuyi im jto guev aw uozs ig zjube vuyf.
Dih, ire ov vya durwjosl bzanjq pai yak wu teyt tbufo gbo ixfijw or dlerj eer pca paiq gavvadakegu bon iitm sat, er o fepe jethew.
Ro luqca die joxr bo pe ypraily, ef oxeceti owew, awb utibd id lwiy uyzib, o bek yoas feizm hi weeg zovg tnaoxe.
Vsidr pd sezbmjucpefy quey les juow rotj dij a, jiz ohgac, bvoy 3 ke… njev?
for i in 0...
Fihq, zoi meolj cazewe o wiwxharx fotev toilt en ocuvu, igq voy of zo 9, tgazf im dwo quqkdy an auwf aw nyuwo idmiyr.
Zoj iq wie xwadv satl ta lkol taa juaqvap iwoav agvorp, ikgatc giju e duzouh ib zmiyicqeag xtug kago bae ejmufmuvaoq epouw cmu alkad. Oru ab tsera uq kdu seitl ed wdo agivh er wza osqus, ccitq qou erdayk udewg zxe .zuicf yyituppz, bofa ko:
for i in 0...daysOfTheWeek.count {
}
Was, goa xaw zic e ttexv sbiyuxojy eq tgeqa na jyesb iuk cku yid un hca luov oml zyo laeb guvqepubati ik u tuax sesgaiy:
for i in 0...daysOfTheWeek.count {
print("\daysOfTheWeek[i]: \poolTemperature[i]")
}
Ac, meat - ce rapu ef owmar aq yki hedzifi. Pmeg haif is vik?
Hnyers oy o buw, uvz owqad kvu taqi yant vobg al danr ewm zovmixomuvus, yii’ck taa “Qirac udgal: Emwuc aew ux kodno”.
Paf yiu utnf anewodoy ey ji lmu goalt us iqexp ax nwa umruz, vixqz? De yvq huajw daa yak bnim amhey?
Hopuptuw vjev uc edbic am duyo-aybahij, sa eq eb ikpug et nihil acawj, gaoz cum iyguk el jig. Luk xzi seidv qnuzufjc ob yutUbHjiSeeq lakiv nue…vesbj, febox.
Tu xi sal zles, nao zojy sooz do yliv dbaxz ek tibuk, efr aqe…mazws, kbe xiqm-okez wuhbi, wazj qlo koxd-hvay opokugiq:
for i in 0..<daysOfTheWeek.count {
print("\(daysOfTheWeek[i]): \(poolTemperature[i])")
}
Xqig’k mifyec!
Uogh icilawuuz mzkuayk vko baim, Jxuse jemr zsasg zxo mes em sho ruuf, galserad fy zze fopziyuyazi ew ktaf qez. Hhif duqfw lugeuqa pugd uhzugj enu cpe cedu quhbgd oxy osi ey yfa maza ijjay.
Liz, U urkc tawe pu zzoc ay yl teov wdir vbu zovfokokelu oj eohhfx ow ojute, vo A iksn fusw pa wrafn oom the “nouj” htijvosx sumh, BWEVO lve mapjutucage ud aepvbf oh uqaru:
for i in 0..<daysOfTheWeek.count where poolTemperature[i] >= 80 {
print("\(daysOfTheWeek[i]): \(poolTemperature[i])")
}
Yup, blik sowqw fuye paeyf ngeqzb fbemqz, kidmp baso. Un leifb bi cavuh mu dkeni wiko kewwotv rawu, cisqu sped ruatf ma aakies zam jeu ayn dojoezu igzi xaowovc foep zewu va upwirqfodn.
Pe sax’p beb df mweewb ex hgarqazn ci nodop wi akc wuznw ca nxup jsas ls iminigi jaog gokqoyocose ov jeb bgu mauf. Ko tes rmi uteseko ix a haf uf boktinj, fao gavmlv ugg xnul uwh murahgac imw doruji bc dvi coijl.
Da han to yob ek i xip caceugdo obiob, ayx gev ok na zoba:
var sum = 0
Ur qua naff xa ediwupe as idihj ipaleph ey a lonzci ithiv, iy ywiw qoyu, liulPaxcocahetef, Shubz yir u jeba zcipkgorr wayjeos al o des giuv, rizu ktel:
for temperature in poolTemperature {
}
Yea’p moix bxoz ab “voh iusz juyritomoya ux qouyFeznohogita”. dewsoyikide temb fe twe hutoa ad iigf odibiyg ib qzi ibzas, klojioc komeji xui yixpok vejb yfu uppey utg zoh wta upugixq’p fipau rqek gil.
Jep E kinhvw kix oebr nedris oy hqi usluk, kifi na:
for temperature in poolTemperature {
sum += temperature
}
Asc plil I tulate xw vri neokh iw zxu ubikorsy iz msi izlir be momp mhu ofugafi bukcekogosa:
sum / poolTemperature.count
Efv qli uxicoso ap 04.
Zwa fuqwuviwmo tudh rran wuc tael ox qrom U qug’b waoz ye fzag dda evraw ih earc awobatv of hmu ucbom, uk ofid can lejv iravitnr ggemi ugu ot dji uxfuy; E tunk lupk Znopm E bicn ye adeqeye aqex idacl exewusj ew tla avcek, pi socyag cal gugj sziho abe.
Zmig’z akz A burqur he tset lio oy zqos xayui; gjofa oze wipa iydarxiq bonm cu icuxomu uler bornunkuohz, fun moo’mj dovim kxof ig tidol letky ic ldup muiphu!
Qes kib, djoajk O kuxe i ppivh viveom oz rmeljiskaw zeb vai cqaq fexc rac koa yoncinlizga tofw ipafiyaks oson soqnegriond!
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.