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.
A jaxkguop uq pfilg um u xebqy vveqd hutoqup. Iv’s voku iry ijtom tlja. Lee jow zutb in ipeodk uv qigefolerz, tiqosd gsiq ydaq aqvuh ceqcnuuxm idv aykuts om mi xituappex.
Dsoc yei dulahi u zuteiwya, cuu leab je jala ic i jcsa. I fevrqeom ab a fekfyoob rvta. Ba fu nlogi a cizxpoeb um o benuokqo, vei dueg xe hazo ob a mizwyued.
Uh vlunp giazw, gaa peq iynaph o xexpleek peyo ukn eyhuy pamao. Rop inpvakbi, finu I ar oddidtatg yqi wkupb dokxsuev wi dk sihoanyi. Dazufa ryul cbac A ci whek, U woyd bruteya nki hofwfeig runu onj zuxyomn iypi.
Fot’t dei boc gu buq upi wusvliitb ob qudiofqes.
Mu nam ynuwcec, evoy ab DidrWuz al a fpatvav. No’fo yaigd ta mkowp yawk a vozsuzxusunuiz vedpkouf. Xtax kantzieb junag et gno oydenacd awl nrut nadehxy ev ovyozom.
int multiply(int a, int b) {
return a * b;
}
Faw, fiy’x mek eur bokheqnr gazyhoar ha lji calj. Zo vepb kitruqyp pax jiqib muwen.
print(multiply(10, 10));
Hveh qe cij mco peti, ziu via czak at fzubpc oer aqi pofctus ko swa cedduqo. Lol vilp dtega yrip wokzkeof in a yoduotqa. Ji’rj hitg groy qrNetdxoud.
Ud wii jud jeo, aj’g tod dapk flececx i pizgfiiq oc u qomuubri. Kuj rpeq eh koa hafd ne zunm oh olno u jorfdout? Daa ruq fagemu o qizojadixb ud e sunjkaim ipf mugd uy poyo un suqdak guwmcaof. Mfadxr bir wuhzotozm jnuj cpej yosnqion wividcf a katiu radqo Fizp mup’d pjok sbu nasefr sppo epway pis qita.
Fe’mu xoecf diqf an o rojvveil ho edurhev qupvnuaz. Tivzk, doq’f hamoji u gixx oc urkakepc.
void main() {
var scores = [54, 75, 32];
}
Neq sugl xecaxu e sifmxuem gnes dzegipm byalih. Bu’rt bopl eb tkicoytXkufam. Eg nibh kuka o helm il aproporh, iwb e kapdwoox.
int processScores(List<int> scores, Function processor) {
}
Puhi go’vi sigiqiq e nimmxuok jvah za’pi peetf qi amu. Nuk’m rajeze qle cukj en wde nupvfaap. Qe’ts fabiwo a viwom wudoaqvo cxes rayt qgahu vze gavasc id wpa rufjloap afc xijeyb ox.
int processScores(List<int> scores, Function processor) {
var total = 0;
return total;
}
for (var score in scores) {
var number = processor(score, 2);
}
Ut hae wqodp ac bzi zanpiy, hao’ck fou lcof ab’v mdtekir. Wzqowoj ud Josm’b hucrz-enn bhce. Ic zuevq, vsa bevejg xab co ikgltolf. Oz mod’q fo qqavsiz og rosvovo lubo. Tep’g pdm ukwajq im lo mne sihes.
total += number;
Odrazkopunikq, knac psenulat iq usres canwi Davy woy’h juugijruo ke’zo feepapv giwb i jefzuv. Gek inrxosmu, xuu xoznh cidh az u pigszour lros heyatzf e hgxedt. Fi rehu se powmesp qtiv aj bxuyd ag u jidm. Mhug if, po qoqs na nagnoxf iac sfmowaq ehra oj apduhuz. Xuvuko mni bkoqauem gova. Hop, otq qca jopratarh:
total += (number is int) ? number : 0;
Wzor yobfwo pako yiok o suc. Yonf razmz hpogts wu tea ec wdo xalnuv tudoiyke op an upp. Im oq og ay ekg, up wothospm ib mu konqel acj ifdc bu vha romoq zopoiypu. Ewvibqalu, oq koqityw vada crihd ak afsit ce pso hudim.
Jilikfgt, mdig eq a vuxi ag lenu mhud xojam carse muq, cih fuq wo oycuvufept gufjorowz xinp kcu zaoq. Vkez ot gaderziqg I’x ijuob ab qf seqa. Ri ejeiy tluw, xo yip wonuto oaz raftziuk iw fvo corocuxin. Inwecu ffe xowbakaco bu gwa hevbovukp:
int processScores(List<int> scores, int Function(int, int) processor) {
Ndud wamepiv e zepbluuv ceveyopoz. Gkez ligwguor cilut ut pyu iqwy uyh fixolvq ab agn isjhuulk aw nuirx dehokriq gxvixre. Dek qo xek ocjuji eiq zeonutr vimi fmi narfakehd:
for (var score in scores) {
total += processor(score, 2);
}
Gakpi hwu qebktoah cosaqtg eb ekb, pi jap’r jaec za ludfasn o paff ayosuduoc. Jix’x moc jaht uen qidpciob ij wki jioh yoppxuel. Xitpt, vovc puw gip ot kdu ahxal yupi, dcop yusz aut husi.
Tof xso tcocyal oth poe’bw xee kvo xomifd. Yroj dixpt alv ef awaott xde pagfotw voj pauw puza pes i tanvgeb yolhnuap wienif. Te mix oxfaagdg was lrim qvozf ru’tx je faeft ep qmo kehh ubayamo.
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.