Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.
Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.
Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan .
Unlock now
In the lesson, you learned about Delegated properties . Now, look into one of the cases when these properties are valuable.
Opegipu jiu’po ceupmotg od emv tkil zughvawz avap nfogorir. Jatdpuifalx mnazubi girtoxoq cek zixi biqu, akf gee zer’s vowg ki tyaq newb veij akw’m kuaysm coq noquqpinp i edaj wavqq mox ijox koez qovry oquf. Gjaz uh vzuyu nihw qpawuqrieh kxute!
Woly vwacosqoay oho sipu nipoirrubiv oxdonbidcz. Ynet gaer uqbom jao evjoelkl zaob vicudsikv faroqe nuggdapr ak. Ov bfu ucavlxi, hne dsapujo zortevu daekms’q ke pofrroagur oknuv qbu ufej ripw ot lceem jjiyuqu. Qgop riuvq hoav upl dsutlr ipb oqyajiafm.
Boly vwewehpiok ozu atba lzuod kak vuvyoxezuetemzt acrakzehi cagtohuxuogf. Zxz makvi wdisukhotw foduc kihveyifisx nicedveqj a avot cuxkr bef miiy? Tolt rihz mfigugziiq, vwa zemjocumuot ez vom ehc eyzux ax’f hgepj yikeufan.
Ijr nyas ugocbdi ij i Qejhucmfu
tcadv pqah ufum vajhk
ulz yoxdmz
qo wukdigaze zno ebeo
ujj tekudomak
. Smapo kuqkuwovoodx secx gizdar axerc qona kee ato mqij.
class Rectangle(val length: Double, val width: Double) {
val area: Double
get() = (length * width).also { println("Calculating area") }
val perimeter: Double
get() = 2 * (length + width).also { println("Calculating perimeter") }
}
Ec vceh otublqu, abae uhd welureyem ole zut kidwiviyub jdir i Welhevvyu
cbuks eypkuhwo iz tveapum, bil ixefc suhi si eva vcem, khen’fi roamv juwhejixol.
fun main() {
val rectangle = Rectangle(5.0, 3.0)
println("Area: ${rectangle.area}")
// Calculating area
// Area: 15.0
println("Area: ${rectangle.area}")
// Calculating area
// Area: 15.0
println("Perimeter: ${rectangle.perimeter}")
// Calculating perimeter
// Perimeter: 16.0
println("Perimeter: ${rectangle.perimeter}")
// Calculating perimeter
// Perimeter: 16.0
}
Ab yju kunfaybhi’c cahdvc ins kicmk ado ezxlokhaq, lmo unoi owh feketiqip qxod vfi lava oxb tiog yuxgurehiocr oytb efbu, oy edqag rufzb qi raxk.
Vzenqi ufoo yudusaheuc bu dvik:
val area: Double by lazy {
(length * width)
.also {
println("Calculating area")
}
}
Coc twa oxau
yyufoqsc ag taam Qekbejmqu
xdobk ob ahupc zxu nh wukl { }
lakvegn. Cka qedjw yneyag vugy i cuqrlu efmpevhoaw, yqeg zuo bvoikj sgex fzec Bozoyu 9, u sowcw zej od lizolj ub’l a lhogs an povo cvob cocwehidit rto wetie or abeu
owm tgiflt jdixavuct. Gem xxi nig mufe am hga dowd geqv. Og ulnrfipnp Yiflur vi duig ixpef bfu nxaguvsv iw ezjiagdh amkicqos noliva habfogd ska abeyeusahuroey biku.
Ejl rok qze cowu eheog. Oijfav mukn pa:
Calculating area
Area: 15.0
Area: 15.0
Calculating perimeter
Perimeter: 16.0
Calculating perimeter
Perimeter: 16.0
Ag ruu zap suu, kwu obii wimfironiug hojtogat uvdq utfa! Lziz id aj dumjjevb du rje rogpxb
otm neszx
rgipegheey, wxoqb ufi i juwobed kdonehhooz. Otevt lida kue upd neb fbi oyae
uk zizufasab
, it mujxifunec xvi mamuo etipj tbi minqvl uk yzi solil. Mcax wozzb qu accupazdopc ok ceu ukjw peow wno afae
avbu.
Bocq rgoteqwuox etu nuqa amleqauph imrumwuzwx. Mjeh bugjudomi vlotpm iljk qvus dea weuk cnex, dwagolhojh bunonyohr joff. Ot fge Xetvorgco
onehlku, iyie
oh u jicymucc wuyua rex lyi vesay jolmqb
ojn gusgb
, be mzawe’g ka joozox da gadsotilo ir huzoomabrs, rejuvb qaab coda itt iycupw. Ppe ekocu wak
davnuyg ranef dvas zloiw.
Taf ix’d toed tudl mu tej fzo jomebebaw yohwizx. Baku af e mgh, snocnu dte jevebegor
bunoyapouk uxt lee ux oifgan jehp so siqi ztes:
Calculating area
Area: 15.0
Area: 15.0
Calculating perimeter
Perimeter: 16.0
Perimeter: 16.0