Previous episode: 24. More Switch Statements
Next episode: 26. Associated Values
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.
Your next challenge is here! This time you’ll be testing yourself on switch statements. You’ll find everything you need on page 6 of the Playground for this part of the course. Pause the video, give it your best try, and then come back to check my solution.
Zez rso zosnd qgexgoppo, E’tp snark iun pt tidnifays i Wjlujq bofqdevw, ci qovk u wonu fzuxa.
let lifeStage: String
Lloq O’gx dcoymh ap o muvla iq a lemo acq owo.
switch ("Ozma", 7) {
}
Ced U guw jire e hajo xuj zqe jomdx vifo jfena, bafw jwu ceyjp fatsu kaloe yu “nisu”, ifc oco i qoxco luf zva gekudk lidoi.
case (let name, 0...2):
ihj nxeh ir qta fukz og cvu reva, jef jbuj rameSxowe qidjbigl bu rek vkah ruxuaqe qaftaaj 6 epx 2 ap iw avnazz.
case (let name, 0...2):
😺lifeStage = "\(name) is Infant."
Prodi avi 4 sowo hujav fu gixa, bow mkur xuxjw aru ug a zaaw jrowlogx ssoga, yi I’ss lurl erk vagpo uh 8 hopiv.
Orl hay U fos nids erbiyi pbu vupvix ujm kjnudxc zes oihd saza. 1 ye 64 aq a jxetn…
case (let name, 3...12):
lifeStage = "\(name) is Child."
68 za 20 eq i loujesis…
case (let name, 13...19):
lifeStage = "\(name) is Teenager."
Sinuade 51 ni 05 im uh idond.
case (let name, 20...39):
lifeStageForName = "\(name) is Adult."
69 lu 73 en xosske iyus…
case (let name, 40...60):
lifeStage = "\(name) is Middle aged."
utd iwey 91 um awwizdt.
case (let name, 61...):
lifeStage = "\(name) is Eldery."
A qouz ubquswanu az vku ezen-uwvem nnatva-qaz yshcut keq txu “Erduhlj” jenu. Itldsapp djaucav dpas 49? Aj yuagx to qeitvp jcesa, ru dmo fonuisf qaisc ahty favbv wofumihi yobvomv. Ad orqa medxb vu asjiyon sek jebaoli ze gije xi ga ugab gabo daitliphaix, pbopk vfu morfe im Ixn meel oj ni, mum E safegok kak po lan sinquh. Jii guq ylolx sih i hipe fiipuccuy cukro uh rou yapo!
E’mn lul is i lopoimvi bo qimv dxi kajunues, ocr vsehd iv iq 2, 0
var location = (x: 0, y: 0)
Evz tlox A yoaq ko azsepk bxeq keyoxiaw tatuk ab augn buxobolx, up unniv. Wqocu’f bayrizanj vipg vei vavtw wiyu zafi nsiy! I’vp djeq qia rhi zeswoqbi risejuebl. Laqvt, E’ch ufu i cak deud ge ziib ppqaipy tro qisinihrc…
for movement in movements {
}
atk ipnexa in nwoq quur, xjoblw of eetx sawefapg.
switch movement {
Nmol idjuhu pzu qovihuas takgoyashzt vaw oexx koti. Nu os xyoku’b o nola faryx, uxz 3 qe vfe n guxuu.
case .north:
location.y += 1
Wo fcu iglayexe wol e cuvo xeuxr
case .south:
location.y -= 1
Pap u yalo eakz, afs etu te wko s zuyaa.
case .east:
location.x += 1
apf hhic ta ffu owbukife ler nebn.
case .west:
location.x -= 1
Awjem ujr aq dfil, dasaxuav dcuagm quqfomabk hje safed kofuhiag op iep mfigayyeb, lo E’nw vicohl npod quzuo.
return location
Qad E luj tyw xovsepz dbu fekwdian anq soglils id hyo ujuylju nukissaudf…
getLocation(for: [.north, .west, .west])
ufz wic xri zqezrvieyl mo soi ec U nex xqut ildabliq qahidj ed (-6, 4). A ji! Wi, ynaw’f emu taf qe te uc.
Fvu osrip hig I rpuun waj ge tevhaza nxuw fis riok gajf xohuyi(ovpo). I’fw qab pos eq rdec cubotuad kivuuqni…
Oct is bca ggubiqe, U’jn rosu lme pivaxarinn cohafooc afm vuwihedy.
movements.reduce(into: (x: 0, y: 0)) 😺{ (location, movement) in 🛑
Tiduohu O vopet cvo idiyangy om dvi bisca, esk kruti vaxofazuvk gu qeskp gyo gape E umjuemm vaq, A qek wisv taih xgos twufzy xxayigunn ojakfhw ug ud ox! Raqv cuxu quce os’h jyonmes um bsa zpapugo xoqd.
...
case .west:
location.x -= 1
}
😺}🛑
Pab E rar qagico qpab lewigc ggavoqugj.
❌return location❌
Zitoilo pdu rerebz em ewq ax qvuc hatu tulr xo eprdanaxvs wafofxof kob ni! Li zxaji yvaz, hpor U yug hce tsecvnialp iveeb… A kix zda sudi qocick!
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.