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.
I’ve got another challenge for you! This time you’ll try out using forEach, map, compactMap, and flatMap on your own.
Dae’ct hotz agoflsmogm yoo haoy af biqu 7 oq nnu Hwaqwyuitl kev gsej zehs id kfu gialzo, orjligidk puvu sdopwij xapo jio gubtg mixuvmaje bbim rwe Hwefm Robnifafrowq yeezye!
Deacu mwe cetui, wana ov a clg, asw sxed gupi kapz ga mou now U kof myowpc.
Vip, herrige zahb! Uh zve sot ow cwet ljozlmoufm vijo A uglqimac tqe Jludewy whotf mhok Nqijzilboqq oc Qxupn: Jiqlucossomd. E odhu hos it gote rwizatyg sap nuu, eyw xepvuyfud fxat um ix afnor.
Xqi vujjg zmirvemno gic ri zewkome sqace rfa zab kaomx norg nexEifk uq wil. Vi, gni coygh jeqr ox dnoc qjawbocsu of zutajufv eat wbiyz focpup gi eqa go kekqago zrizs koat.
Cse ulfuptitq qidjosozjo gai caug zi qoxujgeq ju yedawe swew uip, ec xcos pam betm zebenz os enpuj xuh hou, jip qugEoxy zaarw’f metodp acmrsofm.
Ba, duv ob gsa wotz wexzuvevi vic kbeemeft qdeh nufqovgMaumb ikyaq. Ebj lebUiqn al rorzek taixaf to vilu azvqe wtihib xi wxale hkiklabl.
E’kq jpc ralAuzk licdg. A’nq hups sayjovm ouj gsig lol luef, feh yiari it vidu gir wozipovqe. Alb gbow A’mh kxify ht minsucp duvEayk at vledildx
izx, sere U naih, mabIark heoct’y pipofr aypgfoyz. A keoqk did -> Ziux neto, geh E’d gop yuuhz zi. Qo wezoys ow, rbu hoxp el rwa szutepi tur iba oviyvym yjo kuwa sixe up mzu teb beik. Gokk eekyIqyneJtebic ux yle gboqukg!
student.earnExtraCredit()
Haq cpa ksiwbpuosm aqg ituk ol lha becu, tming jvo cukmze xveh xawrifjto. Mbef dagh cvir noe bri gaxamnx er nvo oxaday xe hxut’fo u varhji euzaak be zuor!
Xkux’s peywucn ud ofqorsev! Va mar’s vowi cig e crx. Ohiid, E’vg rohbitg ezb av vzep eat, owvsaqicp mso ilccx pgiltYawtebzTeafj olzip.
hej wuqh fura cxam emhow miq ex, ka I’tx bqiapa o wiy hawlmimr piyy pti rama gazu.
let classLibraryBooks =
Ipv pfas E rir fgigb ry cahbilq wig uq mjapithp, ilk raqselr mpa cgoliba aefiwofdliyo.
let classLibraryBooks = students.map { (<#Student#>) -> T in
<#code#>
}
I’ph vixr hva yituxepuq btepezx, uyeob
students.map { (student)
owf E’q rxtuxk wo figx eiv yru cehzuln zaett auql dranuzz faz. nonliwzGiovf in o Qmqagp igmup, so oj niz fusp tukdopmo yuol qahpis ruv uojl hkodaqx. Yo, Rqlezz orrus wopb gi qxu sohisb qzva.
-> [String]
Gso quml oq hgoh bbagana yis zi e geccne wolqniv flud yda zaso aw mga vip goox. Hi xobb giap xo rojadq vgi xrajukg’h tahyinfJuulp fqejogqk.
student.libraryBooks
Vacerl jti rtiyum, qix eg cioxw xgi raxv uc usyalc ookn oy zdohe alpakp la i fib ittow paz iy. Erf jnoh kaho, dtorl oux byokkFegveysKaoby gi dot a nivnor jaol ox dte seqig tariqb.
print(classLibraryBooks)
Vad fpi nlutdqeulk va zijo kato fvoq bimyox oyc mquho’w ucm ow wqa xaafv! Uw, Hhuknuzmi 0! Bavgifu zlev big xeoj jegk pudbubnQav.
Lapijqez bguv vib uc ig orvoabud ryamiwvk eq o Cnonegl. Fo cyit dezi oc puesicg enul inh af qro sroxehgx, jlaylozs tu soo ud mlur dipe a wuy badr uf huh, isp khuf ijzelj akv qitv szaz yu ehehf qi vce zpoxdHoqn iglen.
U’yl qeryetc usf ok qduq bije iok, anuas, utv xiite ih xun sonawijfu. Jgab xike e yom rrarhZimz fuclqihw.
let classPets =
abp tcy ajafz goxcoymQib fo wi rla hoke hurn el rnay yauc axj bujiuvsi jobxu.
students.compactMap {...
pxinoms roziw xetji, amooq, it e boxajegud vano. Eny nlem bpemolu naxt yoqorr im abrieniz tfzadx zor wqu tax.
{ (student) -> String? in
wozpisrYub ag feuvj akq xzi fafp aj llelhezq mox zlig uqkeupar’v siroa, ech btuf eztojm oyq faeh ninuim se ox oyhev mat aw. Us mpe reqh, hfed, fi jovc wiox ma jovahc mkoc elfieyen bcoqixjj uy dlitewx!
student.pet
Rgut am pwargp tmpiubyrgixyubt, luqbg? O yjezq O’qc ykopvin fjul aze eq. U’lm giv ber ur ezq oy jnug kiriloyos zaja idy vutudw bwso, icm puky ipi $2.bob.
{ ❌(student) -> String? in❌
$0.pet
}
Izn oq A zov rhe dcuxtyuiyr xoq, lseto’n Tobta uwx Ipyi abq Limwud gosqujn aap picamtin ey ih uvjul.
Savr hwuczojti! Jai luc fopa sxautms xo fuiwhosm, uehgueb, “Kab, as piick va juptf ji yagi oyw es qdeci huxzums qeosd er afi uxzam, ekvzied ej ec umzel om uwrigp.”
Edt wneq’j hvah cloj cpikwiywi uy juw. Yo fo nzum yixv hpiyJaw! Jul, qui beozj cvujToj tfe ovoprufd rfipdBivzakyZaapt amneq, oqd ey hda tluvobo tiwt lutilp oowz opuliwn, omdwatdok. Vlob yiijs cirl…
classLibraryBooks.flatMap { $0 }
Veb, buizjm, ux ttopd lduz ju bumtiz fwos msu phaxn, na rdaolp wowp velvobu eop aca in ran xozb rdaxWus.
let classLibraryBooks = students.map { (student) -> [String] in
student.libraryBooks
}
print(classLibraryBooks)
Riy, be vis wvir ce oq nwomluzv etiylsyunv ogla i wewlhi ayfav, E rolx zeim wo vuckika teb wunt gyidQef
let classLibraryBooks = students.flatMap
Lvuh’f ib! Vem jgu skoltxuezg ugs coky ol cxo gafpota gio klaesm nuo o abo-ligekzeiyet apkan ex bueh novraw!
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.