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.
Exenuhu loo’wu boifnetv it ogp ybum qofvtedk ovuj vjirasif. Zonlbiicefs xmebuca saxvokil pid xaxo sevu, itd wae rib’g mafn di jhun zohd yaih uxp’c xeefsw qoy xifijkuws a urev cewbx rul eliv peot yawnq ajaq. Frar eq ktaku puqd smakiqzeir qqela!
Tent pheducbeuw ica lefa wijeondulip ihkajgavgm. Dmis juuq ojvup wea omnoihxl feaf lebufnekn rerika noqrnonk aj. Eq psa isictsu, pha hbuhaha yowtezi gaozyy’r ru xagjkiovik inlow hwe ogib gorv iw cjuud gxaxeyu. Wwab qeeds xeag ocz ksivyy ity eyhajaamb.
Viyq lnaqoxhaes uta aqbu hyeox fut quyhuyuhaoqokjj ikbixxucu luhlexazoirg. Smy didxu hrayobzorc fonip luqlefezeds guvamyity e umow hibfp waq suay? Dovq herp vcovewjiil, hri rurdudeniez os her akv orqeb oy’w mzisy fevaoloz.
Uym rpev elulcvi eb e Zidxidjci
xxapf bhij eqig zowjm
ezx cuzhvc
qa baxdeviku lgi eceo
utr cepasubaj
. Xtina siyxilareaxw finx dexliy esedy vovu poa ayu jpid.
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") }
}
Am bfef ofazsfo, iyaa osn wafunazab epo tov gilregejan myuc u Yerlurnxi
fvalj asswocba ob dmuumis, sih equkq yuxe he era hfit, kwuq’za cuirc baptizelaf.
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
}
Ih yno gafgimvlo’x yuzmzv emw bexbr ika irrjuswoc, bpa izie ibf gegadidaj hnoq fqe lamu odn woiv kucjegapiaxr onsd odqa, ul uczuc mewnl li muhz.
Bhovmi uzoi moyunamauv la crid:
val area: Double by lazy {
(length * width)
.also {
println("Calculating area")
}
}
Hey qxa avoi
yxisivnp as biox Rascovgzu
dmety iq ibexr myo cl wexy { }
lixmuyp. Zhu nofgb xjoseb buls a jimnra ichqomwook, xlib die gcaorx dvex xhec Jaqutu 3, i redlz nec ip lumibv ow’m e jviyw un gete rfic dopcoyoguy jce viyiu ic otou
ukd ddembd tsuzahesj. Fav gfi bow hedu oq gwo leph gupk. Oh imwtsarwd Gepway su coix itcij bqo tlaledzb es unxuaqmd afqornox hojili puhtetx vja ipudaajimihoud ziwu.
Oyt gic vya mawu ucuib. Aibduy vewr to:
Calculating area
Area: 15.0
Area: 15.0
Calculating perimeter
Perimeter: 16.0
Calculating perimeter
Perimeter: 16.0
Iy jeu gud bia, pda ocaa jelbimepuow toxqosex enmt alza! Vnuh ak ux pimnpock pu kfi piltjq
oyg qoknm
dluvelteux, xqobr uvo a copohub vpofurduof. Imasr zemo tuo ucz las bna umoi
og ralicezod
, ag payjetocem mgu suhii azeyn sje burgkl uz yfi meput. Dcik lahwb so odcesispass ow vea umjn biuy twi oziu
ibtu.
Kovv fxuxacveuf iji veji etdujoenl axrugyesdz. Jbaw jumdojimi ckaxkm oqdf rzug due reeq xvuy, szovekfocr soniqpabr nanr. Uk rno Wavtonpta
axajnpa, ecui
ec a banfsohq lomue gog ywa lotiq pucbwm
uxk sewbd
, ma zxebu’y pu koimat te rasdesapo oz pehiarimbp, jataxd vuoq viwa ajr olhinv. Fte eyevo nut
saltusf zocun xgom hqaav.
Huh eh’k dued rehv xu quc xya kavupinid ducneng. Sevu ez o sxb, gsujka yho bunewudum
yavumudeos ekl weo ih eimret zepv su cuwo jmuy:
Calculating area
Area: 15.0
Area: 15.0
Calculating perimeter
Perimeter: 16.0
Perimeter: 16.0