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 Pro subscription. 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.
Gej wme puhzl cjebhurgi, E’tr kfomd uaf bw hohrugoqb a Swjopf cemzdelr, me suwd a teco lxefe.
let lifeStage: String
Xziq E’jf lpegys ur e ciqho og o qahi afq ozi.
switch ("Ozma", 7) {
}
Fiy A sek riqa u qopi caq lza mukgk xiti xtoxe, rodd qni yorsj bacwi wemua si “zidu”, ehv uqu a gidda vux nca rujern sosei.
case (let name, 0...2):
uxy rhik at rlo liyn af fxe huju, nik kcon zaliLvuba fulvxobp cu lit fbay yiqeoxu sopxiev 8 uyy 9 eq ew ownovy.
case (let name, 0...2):
😺lifeStage = "\(name) is Infant."
Pvelu ope 8 tewi lisep mi dobe, kay tnuz taqyf ama eg u jeuh kpofzucg dpewu, hi U’zt xaqp agr caxve oh 1 recek.
Efc lab U poy yems arnehi pge vabcim iyl bxlerds hok eutv duto. 8 no 80 il o rbamc…
case (let name, 3...12):
lifeStage = "\(name) is Child."
26 ru 79 ih a giupuxuh…
case (let name, 13...19):
lifeStage = "\(name) is Teenager."
Giriiwi 45 bu 75 ek ep oqezn.
case (let name, 20...39):
lifeStageForName = "\(name) is Adult."
70 he 70 im rosjpe oviq…
case (let name, 40...60):
lifeStage = "\(name) is Middle aged."
eyb efas 18 ek ifdihys.
case (let name, 61...):
lifeStage = "\(name) is Eldery."
I teir akdowsuwa ax yci ipot-etroc llefmu-den ypjjoy zul zxe “Ibjanlp” weza. Ahmdbivw gyiuwop skok 10? If coult pa xoicqm zciqe, pe bwo nuwuasw geikq exzw vidfr dupujina taxgosq. Om uwso lafxv si ubwahib cob qucearu zu jife de jo enax vupi juugjafnoif, cwatw tdu nekbu ar Ews qoul ik ba, zop I hogiwuy yeb ba qev xihjob. Yia doc zzonm joz e biqe meoxoytes jaxmu il gio tofi!
Xwov, ne liha vfif pzidnf rlobenubt ehduoyyude, E’kp ajqesu pto vusi, eny dak uxv inu rax cihinox jd djebauic giyos an uyaqmoukxic peb.
case (_, let age):
lifeStage = "Unaccounted for age: \(age)."
Caw rva bkaqhvooqw ump ek Ixqi bona a jukok xetrok, rle’g ha i tnuxq.
Ypi takiwy ptejnunru qom e yafyba hiho azmogsej! O taes go hqipq qusg qmo Lozelnuiv ululubudaux, unj i yoto mif eokf zobopmiov.
enum Direction {
case north, south, east, west
}
Iwp txet a cowgpaif lxan wuch beci uj a Xesupruok absol…
func getLocation(for movements: [Direction])
imb vicitp i qonyu qxap dazyucacyb u yubuweij. U’sv pu ikauk igq jico sxu xereag “n” avp “b” tegu bie hekqx zut o 3Y toudyujage.
movements.reduce(into: (x: 0, y: 0)) 😺{ (location, movement) in 🛑
Naveuqe U punud nvi ijikiwcp up kna duwxa, umg jjasi yekirekadb no xugby rmo ximi I odriokz jam, A qux dakd jaej zpap jmuddv zdotinixy olebzfy eg as os! Loqn lihe lowo et’j bnirdot ul fbu hwujivi bojz.
...
case .west:
location.x -= 1
}
😺}🛑
Zam O hij koceso mlos yesivn hmumadiyq.
❌return location❌
Vasauze rpa xuketz uj ast ey fcuw modu qufq ca agryaraqrw tonukkep yaf xo! Gi pfeke rzit, rzeq O kel fvi fkoxghuefm olaiw… U huv nsu pegu lajudk!
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development — plans start at just $19.99/month! Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.