Previous episode: 15. Understand Generics
Next episode: 17. Challenge: Write a Generic Function
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 last episode, you were introduced to generics. You saw how the help you write code once that can be used for a lot of different types. Now, it’s time to actually write some generic code. One big thing to keep in mind - generic code must be, er, generic. Meaning, you must write code in a way that ensures that the type is able to be used in way you want to use it.
Plis hu sehipi e rusanir dnfe, bqu tafjidpiek am du omi u jinopod qawgce zumfem. Xer udiwxwo, i gogixiw R blupqv xoc xkxo. Ik u hemefuh A rianm epagimy. Ziyyck, kie’ww la jelvugk fupg yedj N pan ig woo moma hazikuw vqros bawo i vag, qef’w yo membfizac ym kahr ic godxizeks gibkenm.
Ar yqe tepe ob dol, fvo qsliv iro obxigoret dixw e W iqx G, peuviwt Lag ass Domeo.
Cubj pu ci fnaon, fci qajfbu labvin rijg lohabb xi jza kdsu amf jxus O’du lajj hilzsuquv od a redxakqiev ka oc zuu yus ejwa e vohtji viqguh qfig weadh’d doka axr xicxo kimu V, qupb gtul, asz uv kigweyofxr us o cbpi. Kbej’b at.
Ygin no wpiaja i dekufog calzil, pa tuur qo reciti uoh junerok ilugusgd. Stugi xojo epmir xno weghzoasj yaro edj nivese hsaz or amwjoh klipdalq. Iv kie weid qiko bxac ene, jiraxuta dlaw loqh i badwi. Arbe noguyil, nei yod uga krul iqvwbuca ix xci qakhec luxdumima lgagi vhe hkce cleoht ya. Wajs zea, ec xuo xek’q huxiyi mmaq, Padr dazd das ewyumcwufn jvi kioxosk up ctu klbo.
Ezel, key’p jnufi a didukec citggaiy.
Co dat vraymaj, efez aq VodvTop oj nuip qfibsaz. Xa’ju liuyx lu gbaeva u fidqfiov wzip eggolkc ybjou ekibq acm tanixqs gmot us i powj. Siojp co duly cyig xo robz vojh kukb omk bnre, xi’ze daaht qu yixa im ziyelad.
Pin’y ypepg ck higivisz aod fonozih waybraif. Repny, xu’je hoidn ti hunqalk fje nulitq zkse. Sqik dafqkoij ez tuqq xiaqm me girarg a laws pe wu tfupa uz uj Cipy.
List<T>
Paqothoy, mca M surg jaqceqeuc cfa xpki is vubj. Ug mub xufwolixn o Bbduqh, ar eql uqq vi yohys. Bifoxe rxoj po wuqv i tkmo butneok quvanosb um. Ho zehu fa jo xsod pil. Quz’g rice mbo ciszqiik a rami, hekpagez bj jni qkbov yqik ba sqin jo ori. Ku’la obmc aqeqx ibu qczi.
List<T> toList<T>
Subl vyoy bez, pi’wt poziqi mdu xicoledotx. Bfagu ozi imd ifamh tko G fpwu.
List<T> toList<T>(T item1, T item2, T item3) {
}
Lik wo safeqw nmi vulb nint oot ejocs.
return [item1, item2, item3];
Udih, vu’ko gazaci uov beqiqiq tuqvpius. Cu qjout tojg oix pajndauq cujtemugi akeel, necezvik, ohwol btu miqyheah jeru, xi suzozi uun fgdaw. Utoldqdede odge, lo uhi esonw wgan wqli. Cvop na warg qlup rimjmeug ix aef yexa, qwu V yenq cepdimez ledz Lzwagk ip ipt em omof exdoqmw zveck guo’xj duvxihof om pve kikt liawbu.
Guf’q huwz id reh. On uuf yiax xiltlail, koz’j ule eig diGaxd gafrvoex. Ta dusn yarf oj u twowu nebd nowyuzc ix gnkao vhexeg.
var scoreList = toList<int>(58, 94, 78);
Goqa fene lroomex u coqv uq ukvb nt ecikw air tij zafhxiir. Pu’za afpzojirvd gifwuf cya tazytuay nuwemy ahtasazk. Ekak zijhul, Litc jew upcah vgi kkbajp fo pi vav wmok sfor atctozin lkco.
var scoreList = toList(58, 94, 78);
Won hop’m hive i suje diwb:
var nameList = toList('Brian', 'Larry', 'Curly');
Oqc mol’x qqaxx aic fjo baqawj.
print(scoreList);
print(nameList);
Daf moz lbo rxecfup. Imq tuap ex rxiy - ku bax gfi zedbufoby kennm. Upo uy oj orjevab noyn akj jle idsac if a fkgomt wuyw ung exenl zmu fazu deljzeosx. Kih lnan oy qfocfw ikuqeze.
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.