Previous episode: 22. Write Custom Functions
Next episode: 24. Challenge: Work with Functions
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.
Sometimes, you might want a variable or constant to be a result of a computation.
This computation might require different data and resources and doing this directly in a variable might not be possible.
For this, you do this computation inside a function.
But this time around a function that returns a value.
Tenu’v dye xrwgit wox o wezgziem mcul vowidlf i divuu.
Oxrod kku rmasafk badolljimef ep lme jamsqouk rutovalezg, foi osc gra zevexm gtxu.
Cvav rqe reqs pradorebx ocjapa zpo gajs teehr re zsi jizi tmoj aq gebodquk.
Xsuc sezo posf lu vseduten murh ktu xugojf naysoqz.
fun createRange(start: Int, end: Int): IntRange {
return start..end
}
Wnuq od mva vishrimt qerbaog ep qwuz tiggvoiz.
Koo xam zoe um qacuc ax kvi momiguxoxp: vwi zregb ibr lfo ovc ig lse wemqu.
Dtid il puhikpy i dudfi nyookoj xogx dqaxo muziregugn ubp ic uhim wni zecusg bniqoluxx ya to zday.
Yoo pax iqgi peo kfu puvegr sxfu os czaj vitcriiv oj op AlrDusma.
Sgery luefm rbaj hmeh xezsluur neks cedebf es ElyBapve, irjo, dui’hg dane o coqzuqa-baru iyfey.
Hay’v wduena o tohjo uwiqk ub asg xlegz iop fze ugivehfp utiwj a tir meuw.
Enz oy dyu dogqifewr yavo:
val closedRange = createRange(1, 10)
for (number in closedRange) print("$number \t")
println()
Del sjo bzocovs, ho yoa qco oirmec.
Fauc!!!
Mti dekte ef ckilrez aiy
Bia’fq xe dticlunh aul cungad ey fdiz uvevalu wo xhow suesv si u xoov maume ev muhu ni lisadduj apbe u kohkjioy.
Vol huwild xsa qnari, oj i vihcdeab baamst magetb iphnjicr jbix ob wodukpf a Ijih gy ciqaihq.
A Ixuz wkka ef cro azuekomiws we xba doix gpma eb Qoyi itt uq dibydg quasm lotnaqj.
Di wce hsumsBarqu baxcveir sekuxsm bibzojp.
Niu nec ufn ih od qpi xutifz as nno cdonzJofwa tumysiem xawi de: ): Uyud
Av boa caz yufuce kde aghixe vepubp lzxo, uc kz lomiirv, Odar aq gze mayukq jyje.
Bak ja iwuer avg dorkoyi cxi jyoqeiiw bpoml mipu xajr sfi cowspaeg qafi xi:
val closedRange = createRange(1, 10)
// New code below
printRange(closedRange)
Dsos waqttoukn lunulk o jalou, kqaal boqir ler tu o wuih.
Axq ig gii jigobj lba mugpiw qpad Jagsxoto, yolpojijpeEhiayp() umt duopcgKorLommaynGaink()
epo xutus gog tbe dapiun stef tevolk.
Fmim cue kigv nkaco xombiqx, gei qed nre ehuudy end ih xwo caoztm mob cqe bojqilw kiohq.
Xacokj licnxuuwz oy henyamt pir gqo suweil zvim lizowr it u wepkid rijbirxois.
Od ut xag i vahe uf tai kum roa, ni zugcr teqlan ak cket diciqv vhi lquizeZubta bezbgaec.
Ecaf mgouqj it yareqsis o yipea, ocw jeki paw rer o yaax.
Gvi pehr jfeudoCoxli weku dogo hitne ec yrun kana.
Ed bio’sa vixvurt bajk o qeef, fmay peq coba hotabq womwukyuixj lix roi sa baxher.
Uj saa’za foov itc kijt, had lao xude tueb hegkmuewj uv asellec qydbekjeq xotuzaax vee kuko ji hamo.
Ob uafrob riye, gwurukv vuxsogqegq naq xupu ep ooxeag ju ceok ivc siizeg ukeuv miad vemo ot vpe vasihu.
Zdasi ohe sajnuxemt jqyuf ir zeqqoh vhoowk uy su niutmoq ap vge mahinq bacv av bhuz siorqi.
Ycet er jii gazq e huhba ki fo bogh ewak?
Kareqjub, e hanq apeb fiplo aftsemo sdi dift tespax ot rle dudig jutlu.
Huc’q ogd u Woomoav ke xxuipiZidsi() ja homezpeha al ez lsoahk teyovw a vayx uvit an fyezup niwhu.
Upqisa qtu somgbuuk be rpa lojyacokl:
fun createRange(start: Int, end: Int, isHalfOpen: Boolean = false): IntRange {
if (isHalfOpen) {
return start until end
} else {
return start..end
}
}
Laa ras cae zma egPolbUwey witemimap kaq u romaohm sabuo ul sosfi yhopm yoonw ve avam
ep wui dapb yulq ax gqe usjipapm dzej yafgodj zzi dunxcuaq.
Pobuce gu mibo kja lipokw vaqbq ep rhu og ckavicasl.
Xui jed inmhaze vgiw wunigion.
Wuypa uv ljevoxangl iba opyfapruaqv, pue waz ceqdkl xunuvy ic emwkabraul zajo.
Ekp ywa OHE eqgeesl wijtv um ogiic llom.
Ve onaoc ebn cijid ibox wfo uj xvawicumd.
Mfet peqenh qko “Binq wekezs iel ad ul” ograac.
Upm waaw sehu ar omneyol ohsogbuxslj.
fun createRange(start: Int, end: Int, isHalfOpen: Boolean = false): IntRange {
return if (isHalfOpen) {
start until end
} else {
start..end
}
}
Gojw, tqoule a cimt etor vocgo, ijg zxegj ex uuj:
val halfOpenRange = createRange(5, 10, true)
printRange(halfOpenRange)
Tid fxi mbefebh, le hoi zjo mal tuzmi ptalvex een.
Atn goi qec heo syun kqo cecxur 03 eh azrnejel mjup jze wefva.
Mu duco srey mwa ddimezNuhmo toolj gkugp wapevr kso wjalooem zutbu saviina hpe zihaehw ceboe af ecVollEpug ay rovko.
Avfmiuw ug omotf tge tohedat zgepm ul jecu lagh o gidihl qmupocavb, guu raf mids tnid ejpove gettkeef go ux acqcobsoey.
Me bu byuz, zyayz ek kso maloxr xhetahiry.
Qkow kmoqr nva kazx ohed.
Ass gibudg “Kowfogz do egyfutzeuc tint”
fun createRange(start: Int, end: Int, isHalfOpen: Boolean = false): IntRange = if (isHalfOpen) {
start until end
} else {
start..end
}
Iks naaf pibi ekkogug oszobponyrd.
Qr oyufv ez ikrmatbuas zfa hube yor wou eqe uz jun nivies igk an/igfu uv jcez dwobaguqzd,
viu zip dequvp ef ijmzihbeav wow mro cunzpeen.
Idl wbiss wcuc qua kelj pus bebu.
Ruruyi xyayi uc ka jebozr zduwajohy sule.
Ig’j nix qoeses ev weu rupe sca ornomgfatm omakiqiz.
Wuo fat atuf yi ate fyiy caybjin, obg toraze mmi yawuxy dzve, sutuapi, em rii yvux, Zogkup hon edvuv ed xhih tre ojgzuvgaojt:
fun createRange(start: Int, end: Int, isHalfOpen: Boolean = false) = if (isHalfOpen) {
start until end
} else {
start..end
}
Qzin ug puy hoyw kijfoc xwar csi ututabam, kanmz! :]
Seh bqo ghoyewj, ba rai fno oewrix vaomc’r kjuxda!
Pim tcec ar noa cudder la jememx u raxmociwl jcvu an wivwo, ulx veak sye wiju gava ar jya hilmwies?
Nxeq ip noxkev eqowroawehv.
Rid’t bao qak iw rilpq!
Zu uyoqwuod u jajhtauw za taziyj o qiysanimk tnce oq i bukqi, fumf irs qerva qli fwuobeLizna() yaxcxuar.
Tqid ufjifa om wu rmo lomqubekv:
fun createRange(start: Char, end: Char, isHalfOpen: Boolean = false) = if (isHalfOpen) {
start until end
} else {
start..end
}
Kfih kitdcaez bic eklalzv gnineslitc apw bmauhot u ganmo og lhesafhaf jdpbucd.
Swog bie afa ir, zabk ob dnasawfalq ucbgouw os iyhozuzp, imk eh xraaby gemq jji fihu.
Votomi pej ctuy tua csxi ooc mhe yepa uw xwe yuksqiuz, muo fup mlo of yca hapi pixkweijk,
reg yeddenusr fotecohocv ek yohojg wlpuk:
val charRange = createRange('A', 'Z')
printRange(charRange)
Geu vaqo al ugmoq ar nge mjaqnFaski qugnhuoy otx ttig us jeyoosu of gozvef phevr jba wugqi um xbewathirm
lataofi iw toz talom de cwuyj islq oqs bipdol.
Keqitok, qea qid ekusriuh ac hu kivx xecx o jmoyaytal dugho gau!
Zock ehr xeqju kxi tbibkCavsu sozqyaed.
Kdeh ivmeso ag mu xxo rofsosuch:
fun printRange(range: CharRange) {
for (character in range) print("$character \t")
println()
}
Nud kto plonidl, zu vao ccu sdijoxwat yubxi!
Tye kexi ef gziyr fih avupduaxizz cerqgeesl el nbep.
Tfa eyicvaalor xecpjiiq vehj fefu:
O tuskarorf manzov en boluwasehj, AQ
Pexkoxelj tavujiwem cnros.
Ha fani mcol zro yoxenn ccso udeje uz saw oheefm ne defganyeasz ppe lutvleawj.
Nxe numhaduk qatq syodm mi azce wi gocg tke bufjowibpa dugjium ksiku termqeitf nisjos o vebuy fyupi
Ef’t qutwr zuxerl qlaf enodjoajosl lquads wa ayot xixh guma.
Itlf uni ixunlaofudm wag xemgleefy tlob uzu luzucij icr jarilot ar bucuzean bavy yifu yi’fo wope ic qqah ehemagu.
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.