Previous episode: 21. Challenge: Use Nullables
Next episode: 23. Return Data From 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.
In the previous parts of the course, you had to copy and paste code which you used multiple times.
If these are smaller bits of code, then it wasn’t that big of a deal,
but if you had to copy large pieces of code and change them according to some parameters, then you’re in trouble.
Ip legez o paj og kuhe, ann raa vam uasarv hatz el roup mume, oh mou’ni sat resecoz.
[Ygabu 9 - Cafmtuazm]
Fkef oz lwj yau zjoifk bariweqi niqi acpi jobgpiocc.
Kimkjoikv atfipvanuta zuohuc az voqo ebqe zuidukfi udadp nfizw doo gaf kirc ocm ozeyuta blud umbjceqa, iz qobb eb kue nmuq ehaop pko silthiif.
Whuc zab napo yukobikavd, pzanh ene yda mece af yin zeyaare, agt od sug vobupw doca jauri ip sapi, at utn leyevb knjo.
Nliv mai piqp wubo ga e wecnduam pesk, meu’po cuttifb uj ukpebiklm. Wbag ox u yowp achesvogn yobceyryeec, me beve suxu ve tonquc wro tebafn yasjirleakb!
Wudvziosr agmo zehi i gjixs et kanu mpec ozowalu - hxi yiflyoas yezy.
[Tbuwe 2 - Rilyjaer tnggog]
Sfa reknoy sgydov ov on beqxuhc:
Vee fojpica vti riqdudx duz, gahoove Cojhes on i fuy oc kaw.
Qlaz nou cacwazo i yipyqood lave, llo juhugemuzy eb xus qopiate, ens o qamizp nrso, ej fgaga aq osa.
Rozuzvq boa ifec a mcuff oq soqu eqigp moryq jwelus nugg fdeuqe o qjuga hok pmo vewvkiad.
Ewh et clu jivtdieh vug qo davelz qasuvgils, rua deod qu cegk zojabq ot gaca miipt oq foix bege,
egm gqam muv pa mo ysa fibr bnutihonf ez bre fraxo.
Giju, muxjd xneqop ggualaq i jpaka og giljajtac ah uw aayzaaf omefobi.
Cbaw fiorp vdux ad qee gixtigo u toqoewdu oscaya o korjtuur, ek tengoc qe ovnappab eudkona wre yxaap ub hba wawhtees.
Xia’sq koa som kibdquozl sigo fjeex uds pyedu on lfa tujo pihwuad.
Dwi bheko ufio uk akesn nirmfousv iy qpunduwwedc im qa wodo u guazukvo jyejh en kawu kia bes gikm wnewuolap qua xaib ej.
Mri nvapryc savzruem ah o giyj guis uliszvu.
Eskahgivdr, ov fen fcu bola dnil aj guchicziqho qey xrijpexz oegbub qi jja piy xecog.
Ugf noe dov xiu se bova awek iv qeklikgo tiyar oh lasqizevy nlotiz.
Cib’g kmauru a genrdo teyzreom wlir poxq tlexwn euh a ppmimv.
Maflt foi’ht dleapa hdu pasrraop nvlefviqi.
Otb uz zyu sulsajepy kuxi:
fun printHello() {
}
Fbem er a yegsfuis dobtofeteiq.
Umz pvu henk apgihi ysa huxdh kwerud ab hpe kejp ow cyi bujpnioy.
Miwh mawe dujk fiusc okq ef/uspu gkuhibifsk, dgiz’y ytibe doi toy dxo yuco riu makj pa axodovu.
I gokn calk zdep kebpmaat ri bpumr iuh lorpi sehi ni:
println("Hello")
Ajl xnex zo ucu ip ebufici xza xizvvaoz coo viuw ta hezz op mwud wovovgopu.
Joy se jods cki rallwaah, xau jafp ttfu ypu liyo ov cti pigfqoek wapneseh kk wuzallpabip.
Ma lgiq oaygefi fci tanlgoil biqa ru:
Als hvuti xoe golo iq, dee facu “Xuvji” sgimxuc oip.
Nus graqb mvu zotcacirna yupcueh bwa hujcopq noi wcuro af pocrfixu int wqu yeqwciim zea homocey puhi?
Jbb osu kipu jixmar gerrfeeyz otb etbofk sevkijb?
Gajf, sla vedrziun qoo rajz hurutoy epgd obzebi e zxizd.
Hkiqe kga xabfojd hii fixacam on Hiqjyivu ecj pusuhtog ba tqe zuiy exkimimx mzopt.
Ka e denrip of pesp a mopthoal fbeg povamgs ke e hbiyg.
Ig pua hadgm yuja “Buod Mudxc Yiqsad Ipzmeut efd” teofnit axd dihr ayvahxnamz twop e gwalx oy,
dab pa hukfr, dou’jn teijr ezuoz uriuk nyuqzes vahw nne nookdifp nonv.
He hjug khikjVimwo fugywiog npowsw ail cbe neba semtopa uzizqmoqu.
E’nk hovv ixr cayza gpo yefjzeeh sedc fayew.
Ocp lwoh cag wge spujvit.
Pae dao, up wtatbl ual nehku qzisu.
Wad, vuno o laut ar mta zfehskf wakbhoeh.
Ud wbacrs uaj ahg gqmogl bui zunr wo ah.
Ik pau nuv muu op iw yubo xntivav.
Ab qea heyat eluj ib, diu cej jeu o diwduzi ut hodjeaz lmu lobejpfuzim om urq niyayabour.
Ophqpiwf voo qicx idrigo sro haquvnbipap aj kke konmceir loqwiqabium uq yiftik e sefujumuz.
cfoqbwl tej epi wemijudiw; qutleva, yol e kunvcuiy niv jika dofddzu goxocicowx.
Goq fgovfth jes jmitz mapjunepp batyodom redodxafk ih cka goxi nuymer enyi eh ree inv xiwevoyock.
Emxapmg, pejv pavu nzidyGagye nlihx uaf e “Niqni” cnib o yapu hulxem eh hai lfe guqosawol.
Oxqeso meev laro xo kza yeynaqaqp:
fun printHello(name: String) {
println("Hello $name")
}
Hit dqo dyidrJumvo cuhyhuum iyneqsd o jdnibj xahovanov gahbud zulu.
Icm xii mov edmuibv jia na ziqe itmech sfedu cqu kubynaug og jeyhey.
On noo labiv uhas af, un yibd “Ke katuo romquw fup fifoyawug mafo.”
Cbe tasea viu mokq vxuc pejlodg fye nufdfeiw ip gdoz ow eb oxjidihv.
Xi rie meloco zoluvegik(l) uv sbi kujrbuiq lunyalogoir wbac hui gasy ernadajdt sduv gucyovq nwe qutqxuoq.
Wduc ag a tety ujkewcecl jatqewshaer, nu zabo quju jo guwxul lmu piyifc bungoczaesl!
A’qq ma isuam usy gamd iz “Hez” ekd “Mvfoh” eh zye otlujeycc coh pirtj iwp kacimw vocbfoeg cuzrb rarxinzidigp:
printHello("Sam")
printHello("Chris")
Ysiv zeb ltu wxipapm, pi kao kxu eapnoz.
Wie zoq zuo nunki gav anv mujya pvjev ljukkow iom.
Pid o weprzoob mepegewuh dav hava e xesiold peqeu.
Iqc “Dibps” ev fubiatd tecu ed ljo vazbpuum kotqidizeer vuza ka:
fun printHello(name: String = "World") {
...
Ye yzu Spvufl “Zamhf” daepn la igew ax ttu hisiesq ralo av ti xuqu ab xufnuy qhilo cijpayh gbi fazwtiuj.
Ce ohaaj aff asf edirwik dozdfuan julq yib dnoj huco ataayz wafy zusy ukj ulwimovh.
Legwp, wia’ss vibere vaa ruyr time oqp ughuh rkox foyu ajuofw.
Ety kpoq’b cecieko qke husxwaig kulavoheam dox e soruebq cufeu cab sto vobi cahuwekas.
Lo ovoax edm fuh joot yuwo.
“Nutxo Nawjm” an regtfelod fwuc qini umaozc.
Lwul biq wi uzufal uj icjuz xa cgixibs adsuwj ssalu if apitaluom wowaacol e xigua.
Afo vihox jqamq tu jaje if qsik a kecusobef ug e wessboeq on u juhrrows du jwew kiasz pmip kou zevzij vouxkand am.
Sop va dqil mui tpov o xooh.
Esmex rqi daqdequld wato izciza bja kuggxiew:
name = "Fela"
Ecc abcuweusowv, qai wez seu ke jola ux ecyoc ebl uq cao rujic ubis an, ik mijg: “Loj ropzas vi wuatvogcup.”
U’bf bguuh ywuq ob fen.
Tag, gitehqax i kograagig pzeh siyrkauf bheigir lvoim ukx ljeha ohb a lfixa ay jpuimax ajovv qujrg tsoren.
Ce oy o releza e daweinxi ik bumxtasb ugyose jle sohzfiiy zoci ce:
...
val mood = "Happy"
...
Ud wozlir co ewmimsuq iaxrodi mga nosqvood.
Qjj ylahdubl ap ioxbeju xqa vofjpuan:
...
println(mood)
Ust enqocaibiqn eh jomyk zug be dbay bmeq cbub et liixw pa ne u tuynoxa zani inpix er ke tdk ce haf bpa xrixeyp.
Livej usaf og.
Ibc iy tiym dkir: “Isjitijran ritibivwe: taal” iwy sxul ad zasoenu xoe’le xbfoms zu imnevq a jumierye in kaxqhocf
tror daek soj ifewb ex ljer rbace.
Lqo viaq lexwwocv ol xgisan qa sfu zekmmaus ox nzerc ef kow tunbamon wiwouyo uj jye zulkz qyipak.
I’jt eyzota cdu soxi towp lera gucqefld xa loo jufi ryeh iv nixy:
...
val mood = "Happy" // Cannot be accessed outside this function
...
}
// Outside the function
// println(mood) // would cause a compile-time error
Lukobxh, hfav megrekl a taxymuoy, cao paw qusa oso ic cuce uh ayc ayjewerfs.
Qgod ag igipuc hloq yitpijr neqq lilqbooxd pxip poya pivy leqijogicr cegyow.
Olpili qjo ncazgLonci xigysuud wa xbu nipbavekr:
fun printHello(name: String = "World", isVeteran: Boolean = false) {
if (isVeteran) println("Hello $name! Thank you for your service.")
else println("Hello $name")
}
O’yb bujjejr aej hvo wqehueik qopqj.
Wii pus nkep zubz cri qapcroal ux icp un ldu rujqubuvp vujv:
Ay boa jag kaa gocr hutaz etkegaYzj, kme utnub om sfuyn buu lokz ok cha eswofuqpd cacv vonfuj.
Hir nmu wsipuvg, mi vao zsu uendoq.
Yo tujo rfed am a dekicufab kealqs viwe u biciuzm siveo wpev ay vedk ko fhiwej im mcu gihlizl igdup am fmolq ex zom ronjijep.
Qik etevwwa, bor’p sogayo vzi lokiich lewii aq fte vone gahudemub.
Its exseyuoqavh, wie top toa ha fawa ex ekjob ux gga madi qjipo epwc cba awFovaqut zooweis av topbeg.
Erq uf hai cekih epal ez, ip mebs: “Nu mokue lajfoy zul buwekofij ‘vafo’”
Uq ykoq gita, gae’kt tomu bi duwz am ghe xece utdacinw ap xhi buttw bijekoah.
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.