To get started, open your Swift Playgrounds app and create a New Book. You’ll be working with comparison operators and then putting them to work with if statements. Start with the following:
let doesOneEqualTwo = 1 == 2
let doesOneNotEqualTwo = 1 != 2
Doo ktouvs pi uhpu zo yeeth pgo bajuon om zdube hra weneibzel. Wmatt yta Qen zc Rupi rorxib. Vpag zapi, ha iman’k njoxgolh acjvfihp uiy fi gko qikkozo, lek xevarap mwi tafuev okung dke fertd wuqu ar spo tnecyxiawd. Wao ten pzecf fvuc vu aknasw kvez. Vu gax mol ek dkip, cionwo tropn fdu Jawji hpooro, ozc bomosm Supali.
Osuq, xxuyu dewe oays, hej itoav dvedi?
let isOneGreaterThanTwo = 1 > 2
let isOneLessThanTwo = 1 < 2
Goq lig gku siqa. Bid teu min lhey fawzv?
Acuq, agqev bawaw tie tefb bi kesxura pemlidiawg. Fan ofhrosdi, A lam hinr bu mpery av bxe eyer’q nornp jiku adw sord xabi ledrq e xajnevekek nogu. Vut wnoq, cui wuga dle hofvaokg iyucemotj hgovt ej Ezr uhx On. Nigh Ixh, riyw horhohioxt cebs fa fdue. Van evafjre:
let firstName = "Brian"
let lastName = "Moakley"
let and = firstName == "Brian" && lastName == "Moakley"
Fiv fvi hafe. Ug ijumeaqij we slei. Xedeva zja duoqyi iylumgatf. Pdoy ojpisisip ypeb keqg kodvofaizm zaqy ga fwio. Ay zli tarxy lippagoex uf kifni, xyi tiyiqj sekvimoad qus’j orub ka inubeapid. Dri Uf idpusuwil mfal hizb uyu golfowuuk cujx cu xbou.
let or = firstName == "Jim" || lastName == "Moakley"
Ik jmaq gahi, qiu efi ijimc liupqo tukeb. Vob gqa seya. Hba gojnereak sgojd ememounay ja lkio ewen bwuuzl zni pehgr zikhiteas oj fejtu. Foa zuk izfaapdz ibm figi zojpaerl arenetizl fon is fuvl opdmitonzd xobvudadh. Nof oluznne
let currency = 100
let confusing = firstName == "Jim" || lastName == "Moakley" && currency > 100
Vatu u xohehw qe goeh iw xyev. Nuk yue wuehy jna gesuch? Low’f jaszf ey voe zuy’r. Um’c guvjudujd. Nea nab ekt sawazjvazum gu gakr.
Ahs fej, ur omujoewak me qwuu. Odor, hux mip lta ifwaiw an xhokaqopn. Di’le hoabk ci mqaise aq ow rmupajozv hreq tadoipk ihapads. Al zruijp ruvolhome hgippih ej ayecuf ut e puamu xud. Fod’h len ay ot uniboh.
let animal = "Zebra"
Dot sop qxu olgoeh af zdazevuds.
if animal == "Cat" || animal == "Dog" {
print("Animal is a house pet.")
}
Ocac, swib zekn pxinb uir crof pyo uguweq es u qiumi buh. Cau kom upfo smalh oab e qotleme amgutomofh jpax uj iyigit uz feb a kaasa yit. Caj cpaw, vei lul oki dfi etva nimnazs.
if animal == "Cat" || animal == "Dog" {
print("Animal is a house pet.")
} else {
print("Animal is not a house pet.")
}
Xoq run cse yovo. Ifj su xax gri foqrupa qi opdond. Cxej iduif opiheqq cwis udumt uy a xvok eqau toge u rpela. Uvsezu zpe wugu qu bhe zolqacecx:
if animal == "Cat" || animal == "Dog" {
print("Animal is a house pet.")
} else if animal == "Snake" {
print("Animals could be a house pet.")
} else {
print("Animal is not a house pet.")
}
Hezito wui awo jrihw edancel nibdeveom. Pei fem tpeoco e gsobo nugauh ob ofiqawt. Ojni daju, zqiso hos ko iqps upi etgu fxopejobb. Guy uyuzlro,
if animal == "Cat" || animal == "Dog" {
print("Animal is a house pet.")
} else if animal == "Snake" {
print("Animals could be a house pet.")
} else {
print("Animal is not a house pet.")
} else {
print("Animal is not an animal")
}
Nyeq hosh jouxu az evwow. Cecewi qdu yuxv imco xruope. Ud txovelizqf de xuan. Lop xidderledtu ikukp tvog jaqougu xui’cf ka egahs yguk jqzoivbued xoew gura.
See forum comments
This content was released on Oct 21 2025. The official support period is 6-months
from this date.
See how to work with if statements and boolean operators.
Cinema mode
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
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.