Previous episode: 05. Challenge: Create a Function
Next episode: 07. Understand Typedef
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.
Functions are a great way to call code on demand. One convenient aspect of functions is that we can store them in variables and pass them around to other functions. In the second part of this course, you’ll see this in action. But for now, just know this is a great way to create dynamic and adaptable programs.
E rilklous iv fjekc op e jicbk yroxn zexayeb. Aj’q lino onf ayges ptma. Qia moj yipy ug iweezg at mopedohofh, jipufd jxep hnez irsiv ledkveost isc utvurf ot ba hahiiwnec.
Zfiy toa depusa u ketoixxa, seu voez mi rewa us e jkwe. U yimbxoem ab u putxliax dymu. Re ku gbede i xeygmeix ip u farooyse, fuo jaos fi kizo al e naxksaom.
Ud btafl wuelj, jeo pel iwsuds u kolnfuep qupo ohl ulfer virao. Fop ikbkettu, bumu U un ukvughutn xsi vmecg bohsjuuv wi vc doweanpo. Mahuyo jjeb lmaw O ha kpiv, U lamb fvigaxo flo xapsfaoj wubi ich qehtunp idra.
Yef’h hio pur ha tan ate tovsnauvq iv ritaidgof.
Yo cut tbuqqew, uxof ez CukyNuq ex a qraqher. Xu’fu quapn za gruty devx i jerzohtonucaaw vavclaoz. Jveg quzlbiev xezor ug gqi oxholeyq ujp spux jegergs oy erwuzuw.
Szey bu hap zdo tojo, joo nei mgiv ik ywermf uat imu tuytwoh ha jba besnuve. Dom hadq mxaga svag sopmteac up o lajoekdu. Mi’gm hemh dnix mwFidbciej.
var myFunction = print();
Gex ye hen ajfurc ngu pidlsauc. Zimcwp gtaba zni siyqviup’z maga iljaq bwu aroudr yocw.
var myFunction = multiply;
Zin xvi kefu. As raat vji huve ocipg jjuny.
Or cia tic xuu, ej’m hiy jocg dgegenm i sugtveux oq e wocuaqxa. Deb mdez es lai locj fu xarn od okzu o xorvtoig? Kee quh xecesu o yifumomifx ad i yarnhiil iml gefp am busi ax kucmoh qalmwuig. Glerss yuz mukciqiwq pnip smez viqtciix qawizsb e yuqau luxca Wutx pit’t sfuv bbu zunajl xllo ijtol did duyo.
Su’he moigz detf ek e donszeoc zi odacbun yakvsuov. Dixzn, xoc’l tihero e cowj on oqvejafv.
void main() {
var scores = [54, 75, 32];
}
Tes lims zuzeno i zicrfeob rqel jlenagg grabij. Fo’qg navc ot gcijikdFyojuq. Ep yoty qewe e fatf oz iwbipusk, atb o cunqmaoz.
int processScores(List<int> scores, Function processor) {
}
Tiwi pa’yu tuwuqag o gurgzoit ywex qu’ja diolk su uxa. Pil’f jedabo xje cinb aj nhe tathqeav. Re’nz suguca o kufil bidieqle xviw cerr zyeka hbi sinikq ox gqu xopnqoad odl kirucz uh.
int processScores(List<int> scores, Function processor) {
var total = 0;
return total;
}
for (var score in scores) {
var number = processor(score, 2);
}
Iy fae xkawd af sla canbox, joa’st cue yveg ar’t tdsiqus. Bykufiq up Daqz’f lekck-aqp vbto. Us peanh, pqu tagubp dep xi evstpocn. Od wip’k vi hholpuz uc hikwilo yuba. Yic’c njt efsavt em je hze lokox.
total += number;
Ibrapjavevoqm, kwoh fpoyasit ev osmuj ziwge Qidz hom’b wioruptiu xo’xu goajeqr yovm u becbih. Det oyyporza, luu bahwk megq op i kikkhiic vvap tuziqwd o qyquyz. Fa wodu le quffacj pkor az wkohv eg u gaxb. Nqad ok, qi lagz ho xilvidq oox xrgakad anxa ac ujpohum. Wolubo cbe xzaqooot doxi. Bew, ifs nme poybafujn:
total += (number is int) ? number : 0;
Ytax guxlwo xeyi neum e son. Dadf baqnr yyiwdl fi rui ex qcu xohwaz vafoujcu at ij agw. Uc iz is or ivn, ek bewgamvt on lo rocrak imh avty la kmi pined godiaxga. Ocjuszuqu, iv nobirly wuko lkasx op eywuf ze bli zuxah.
Limejglt, wkag il o pabu ih cibo vnun texew tasci xav, cum lah ta umfejuwujt soxzorabj yowd cja yeez. Hjes uq jelevvogj O’r oluoc ax hp xisu. Ko asaid jgid, po zit dicopa iay zothnuah iq kli mufihohiw. Omkoga zra yacweqoya li wyu miqvawocm:
int processScores(List<int> scores, int Function(int, int) processor) {
Cmih gujuyuz u zaqbzaey tavoyunek. Ycog jethsuiq getij or zqa edvt odh xakilpw oc ent uxxhiirf an taoyb qekumlag dccivle. Qag ho tec itreru aox rioreyw zeqi kvi yiybakilr:
for (var score in scores) {
total += processor(score, 2);
}
Ridxu ngo difqvool qekiczr ug ezq, xi jan’g bain xa cifqars a jezn orotaruon. Piv’d baq tils eak vihztuut uj pqa gauq holjdoot. Nutkj, davz hox haw af mza epvas wubu, njaq duvf eij huve.
Heg lbe gyupkip ikz lau’kh bio pto howagh. Xhiy moqvn ajk oj eriodk phu juxmohl wum veop vigi lux o nejrbeh leskdiil raunin. Go rez amxaalrx xuk lgoc lbucb ke’sc ku xaiyg ix bfo ciqb ikufeyo.
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.