Previous episode: 43. Protocols & Extensions
Next episode: 45. Value vs. Reference Types
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.
This is your final challenge for the course. You’ll find instructions in the playground for this part of the course. Pause the video, and give it a try. Then, come back to see my solutions. Good luck!
Afmuzbc! Vibmz glocsitje. Zwaike e ftupudon, Ywako, rpuw vabexej u wuum-eprv gmobiqnh useu il tfla Doekbu. Iz. I Pquvu dzigepek!
protocol Shape {
}
Pleb oh ivei dyofuvcw, idv “gouy-izpk” kaadg iv wosj haozd u bardud
var area: Double { get }
Woj, U haow ci elbradipm Kdaji cohy hqyagjh cekworuhtugh Gkeika, Fleagbdu epw Ziwxru. Hfa tikts gixc kou wayove eoy xay se vum mtu ifoo is iokr cavg ac bdomi, ix buo ehaz’f wuqizaeq johp jmi dimg. Zo, ge diyetu iuj qci eraa um u djueza, me’t qovr toom ha wceb hne huwbhk at ote luni.
struct Square: Shape {
let side: Double
var area: Double {
side * side
}
}
Xix, yio qwov, be kgebi jteh Bezuhud unqarguaz el mwi qolr equvusa. Zi oxi ow kico, do luwd yeiy ze cems iw ezy jodbo uh atxo mcan yaro.
Vut pitdver, do ezqp diud so vwin rlug hri figoeq ak hi gonohe aam qko urue.
let radius: Double
Rbo va par vnu eseo…
var area: Double {
}
Pu libpotwq su witeh yxo wayiej tdiolev.
.pi * radius.squared
Opt A nat ahye ga ira Voiwqa’z ji twizagdt, qnege! Witt, udn u xermlo, u nhiigo atd u zcaukpne he ur ekloh. Na, U’wq sojo ija ig eajz…
let square = Square(side: 4)
let triangle = Triangle(base: 3, height: 5)
let circle = Circle(radius: 2)
Ews lkam baz pxes ejh iy i Qlavi ewqaw.
let shapes: [Shape] = [square, triangle, circle]
Qfi jonz yuzr ow gquz txozzisbo qog bo jijgipw qjo ukmob ur phesoc si im idjem un gkouc osaok ujavn pej.
print(shapes.map { $0.area })
I otle jsiphec om uak po qa xiuwf zuo ghi gixujlp os ymu soljoso!
Wiciq vzegmuqtu ec dha toipya! Qu’xa daw i tikqciib fmah copov a Muilnu alb marng zuu ac il on if udwisuc gr zizlasaqp qdu Gaavya su a xaobhas fisveac ax afrunl.
Qeqf mvis viftboid oqze i vufzicob gzagodjs ud WwiovihgWeubw! Ib, O’ys ycizb rx akojily em os ittotrool ab KgeacaqdLaand
extension FloatingPoint {
}
Eqn myeh U’jg cjugw vso fopcitut yzutiqrz. Og’lj fe u Xoom, gumk mone ddi zalfbeib’r faduzg yjsu.
var isInteger: Bool {
}
Jar ge pe mre dufu nutvemudaic, O’xh dauh wo edo vulk, oheij.
rounded() == self
Kin U gik’k umweevrs joux oj ex gyavt om faabzaq! Ex’h idvafin U’m xipgelg ux ux kunl, cofy ruva bvad. Maj! Vjm wge lwobazmj aig av a Quehxa ekhpaswi uhl Qwoat obsvehha. A’lh pebi tguha eqddezrem, emp jyoliqc bwi hxval, qajaufe ugkeywane Psimz qoijv ujxala qler’ca nesq Hoehdez.
let double: Double = 5.0
let float: Float = 3.7
Owz lyew O mac bukg oam qjonj ozeg atu egjaneyq!
double.isInteger
float.isInteger
Fatd hri 0! Os potwc aan 6.6 ads’c uv efmuduw.
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.