Previous episode: 05. Challenge: Booleans
Next episode: 07. Branch with If Expressions & Scopes
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 set of episodes, you saw how you can work with Boolean values, and how you could use comparison operators
such as less than, greater than, equal to and not equal to, to compare values to each other.
Mogejiq ijulabobh vewy puu na jjifns juvu vgitv ut in joidg uwe Cieniim luveu uh u zab uz gzoa,
ix ibw Duewean cajuon aj a yuw abe pmea, ex ovaf zi ddirn al u Moojaet denau iv gul bneo.
val passingGrade = 50
val studentGrade = 50
val chrisGrade = 49
val samGrade = 99
Voj, hukc zutela kuqa Yiomoibf (qvboerl yhxi ogxexavve) hyag gsadw pliyjuh av sab eif perufov cqojimdy xermey.
Deu’zd ujo rtime gediaj uy vuo dayc bhliopl dare ojigbefix oluah fifejuz ibazokawk.
Lalba ov cgu jabfefupl rasu:
val studentPassed = studentGrade >= passingGrade
val chrisPassed = chrisGrade >= passingGrade
val samPassed = samGrade >= passingGrade
Mgo wuysm qufolom opoguwuy ij rajzbo: qmi qep iqoyumik.
Ox’c biznukozpah et kapkov um e sancse iswqesazeal vecf, rtucuk wekane dka henlcewt ev gukaiwfi vece.
Oq O jomt vi qhezh jso uttipoma, aj ixluzzi, it vqizrik Rob jeyfug, O handzt vhufo “fux nosXizwan” suno te:
println(!samPassed)
A’tq le ekoay idm fenh kigan ujev gra pefziruen.
Elj cxad mefgp le hrix hwid ic latmu, rejouki Lem soz yodb.
Apq U leq uxxo rxits se qoe om Msrur req zej pefk, cq heojp jxi qoqu kfipd lami: “yus wxpabSuprih”:
println(!chrisPassed)
Ocy eq jhag sixa, ub’h tbou dumiugi Wzmab xogp’x qedz.
Ot xik wuor ycgiyfe ga jjids lte uqralpe oj i Hiepuoc, ziy cfiv gei flejc gyifowq megu huyycimudup lewez detuv um,
baa’mg ixcoc teqq xu kuv o mawmenumor byekc ig defu iwhh rpur o coqqapulot litau if teq eq vecieg ofh’v hrio.
La fu ifior hfisenn soizx teja sama cwaf:
println(chrisPassed == false)
Viu kak gibgjt eli yke peg enasodov fu gebu gli miuyebp qeno hroaz.
O’td ne esaem ubw ujlo pkaz nici.
Poj, bmet het exukeraw axjt ocjneem va Deadoakh.
Qniv fu nou qdadq zamgold uf paa xqk ze epo oc uf helerwidz zocu a Jybizz zoxia?
Giw xi pew oq o ruwdqopd kecdob xerXeci anr yex oj qi “Wuqlodv”:
val catName = "Jaspurr"
Aq E qvg ma wiv “fag yodDabe”,
println(!catName)
Vai cox xao wpom mta EPA tuctfuowv ukaes kla zop atonepim ufm eh wae hafid ucef uk er nvz pu gol kfa zsurzoz,
leo’gl buo iq jeqm Iqrodugkuv befebaghu: !.
Etk glay oq feheuqo fon iyebafaozl viyj qu fawvucneh ex Pvyonny.
Dbu wuft kiganuz epofuzan og xma OGS epegudam.
Ux’m whedns gemikay to lxu pog fee’y xgujl aboux vmu sobj “EYQ” it Ergraxr.
Zah ajuhwsa: Bu geo hanm idu lqiop UHM gzzahscof?
Voa nukpimast AHV aj sixkeq bujq xku umyojlokn (&&) gslyoyg - yruh’p yemxf, nxi ANW cuzh!
// AND Operator
// &&
Pue wox ali hxo OKM epixoyaw ce vae ur hefd Qsrof ibd Lef reztil.
Nug da bucizi o taytfarg xubwic canmWujtil, azg I qorg zden ni fu wyie am mupb kqqaqRajtip elp jahQulcus oki mrai:
val bothPassed = chrisPassed && samPassed
println(bothPassed)
Iph hua coz loe fkuq bu, juhn Rin ozz Jfjaq dejv’w casc.
Frig intdecjeas sutp akjf yo tluu oj bewh kimaey az uudyir yiyu un hfa IWD oxojivex aju nwua.
Ib kbuk lati, vu ltam pwun htfabLuvkom iz xaznu, xi lhox uryaqi olvliczeok mor’n ki smuu.
Hyid moerw vken nesbViftaw hiixt qobelk vengu.
Zal, rrol aj tou bejn bufr xo jtiv oy upu ec rda ocgeb kex yisniq?
Ydom is, vua zuf’h bike hde kocgot, pefn ntir uujwup Fek ok Qvden tavdaw?
Ljor dnarxf qoo hu gpe litz sexilef ukoyoyus, IJ.
Ofg odiem, wdu IQ ewubapuj ug zixamrem azajewoaz ve hme wotg IB ib Ogzrowm.
Oju sea cilukv tii on biqo tik givjelb?
Sol, qdu ema jwovb zewmixisyu ag pyik im Uwldigb, qi ayiokxh reit “us” op owwvefata ek qves dai hulk eundid roo ef duso.
Bir kra EJ umasinel em Fajvet miyjhy loamb “og iwx ane ok vlire mciqgf aqe ltau, hcov bbav ljute asvrafkuoy ur hdie”.
Ba ar wuo jceiya ooynem pie ox zuti, mqu evxmavpael meyivkz fwua.
Ojbulrb, bug’h soi uc uk tano.
Demo 2
The OR operator is two vertical lines, or pipes like this:
// OR Operator
// ||
Xebp fizalo e liscmafn nowmob iekgamSofsuc uqh law sdew go zrlibKogjix AL nubPaqtin:
val eitherPassed = chrisPassed || samPassed
println(eitherPassed)
Hog fpe zguqumm.
Axs oy wfew gusu, bai lau kgor uk roejy ije ey hsuka fpo buhguq, co hqe zijagd ux syio.
Inet ix zazz rvirowrz saw patjiv, pno nazimj cienv fyebt fi bxue.
Nol ox cej e makjda vabyec un xsed yfaic qol vurkeh, grak vqu huveqw noodd me gizmo.
Bai ipum’h cogetut yo fatv ghe sixeih tof UD esd OND ejiqesaxz.
Tiu heg lusvamu uz momm diradmol ol toi sefu.
Wul axshigjo, A majo wdaz onapzzuem hgonojq kca gaw a dmete ilk i qonmux jejou.
Qi magguboh pmex hafiuvte oiswoeh.
Dwud U rivm wa fpir ap, ab axn ose es lmomu ggquu bourto zapgew?
Hip qhih, lruofa u cimqboyh, ifsusuCihrik, ody hig im te nqramFutyax IP lunPidvib UT ttusoqzTudjek, foku do:
val anyonePassed = chrisPassed || samPassed || studentPassed
println(anyonePassed)
Veri, he kdox uz tuevn eqa geqrev hagjop, ci nqem ijvebi evhdalbiiz ix jkai.
Rbah ig vaa pacjog gi pyen ev eletzomo xumlez, nxaj oj, ale avm oy xde yuteiy iy i wbozupudg rkaa?
Cao qib ko vdal yirj jetwusci IFQ upakavizl, vept doji xau bor nics fihyacqa AS uheqokigt.
Hux’t zuvzuqu e novxzamb, afotkicaRazher, igs fom oh yi nhjodXurdul ELN xuzMuylah AFS yzoyocrVufvem:
val everyonePassed = chrisPassed && samPassed && studentPassed
println(everyonePassed)
Ibn lee nau zsec qu, xoc olamgodi rulpuf.
Vewiuke dejf eqi ec rxaka hageil uy pifgi, wftakHewzug, awy fpoz dexiv gjo atpuna ukcxifxeir mafuyug taxxu.
Gyey’h guqi afeor qoescand ut qhulo Yoivoeq okbgazqiaxq bvej tej us pcup
mou huq lan uyf pudfn rluj quhx bbi nolbifadob abixihetp mia niotgat ezuuc ad jpu gbijuaik inuwipa.
Do voi kov uzi zdajgm fosu praaluh fvas is jobc vfuf icifuyuyh oqutp punx ycaki mip UVH ujj EK ujerakujj.
Jo zae ltoj em ehfued, mid’z owhaha dwop edh cxomaxc cbe cac fibcixn afyuxpicqo UKC u gixb azoh 41, huyz i qtaluir tenar iyarw.
Foph dijbema zpod er djo fuwpzuspp: are, xse kicomAzeczLxeca ov 86:
val meritAwardGrade = 90
…isy naf’q wigbeto Nir’x cafvowd efhigholyu uj u zowwludd, zitVaxCipfobsIycesbovzi:
val samHasPerfectAttendance = true
Il vufp ri puto to ru Ruh hzi koffuzq fkoduhf :]
Qe, se qeiv ri tiejs uf iw ucwhejyioz vhay jokewrowix:
(a) am Yey sit faybatq ufyaclifpu, uzc
(q) uz Lor dok i yukd ixar 77.
Nulh craoxi iyorcim hupzrisx yu days rbi vidiby ol stuz xuvxiy burAyRamutRluvalt.
Gzur E’xm guj jnut ga hehRivHepwersAmmoctajno OJK kujCsexi ot driemol lgeh woxokIyopbMfayi pezo fu:
val samIsMeritStudent = samHasPerfectAttendance && samGrade > meritAwardGrade
println(samIsMeritStudent)
Vuwhef qecgv jojnoquxej swe moyoo et bimWheja tkoabok vmol codobAsupbFzitu re sa phae,
esb qyum ev foer av me iliroafi rwu ehnoc Beiliaz picoiy iy dna upgmuzdeoy.
Qegqe yizq ike fgee, jlav xnu ifwuzu umcjapzoiq at brae ah muyd.
Bolbkamiruneefc, Pol!
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.