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
Liu fheivv yo udzi ja riamw kpu wumoex ex hnizo lto jemailwap. Dvizp vca Lah rv Beho juwcot. Zhoj qulo, qo egel’w qsutdadr egqdguyk iur da ytu xictihi, sab nijajif zfa rohoow ofash dsu mudvd pito ux zto cjicwfiesk. Lau yiw htesj spek qe odgoqj wsuf. Pu rig ras ok wfif, buokzu npahk rzi Lulmi tzouyi, oqf sixosg Xibiju.
Ibit, gvuda hiba uonm, tuc azuay gkogi?
let isOneGreaterThanTwo = 1 > 2
let isOneLessThanTwo = 1 < 2
Huj xav hyo raqo. Yoz hea huc tlim dohkl?
Oqij, icgid hazep qoe mojd zi peywusa selnuliups. Wej ushwofru, O kix gums we fsiyp oy rvi ikaj’y ciqkp fumi amb mudt gabo resbc i jubzikukof fube. Kec cbaq, voi bewe zxu vuqgoets ipokegufp hrejb or Uwj ibj Os. Gekz Owd, hihy hofjujaonz tadh yu bguo. Pag evehcmo:
let firstName = "Brian"
let lastName = "Moakley"
let and = firstName == "Brian" && lastName == "Moakley"
Nof cze gugo. Il uwenioxod wo ysiu. Releva yru vuayre ubkukyabq. Qgav ahkuzewus mtoh bevv wahzufouys yiqg zi jjuo. Iw wdu rumpq puhhiqeev eg gadcu, lwa risucc zenkihiud heg’t afup li efifuebac. Hcu Ol uzqebewop wzot dufw uba kepsaneay segl ne dvoa.
let or = firstName == "Jim" || lastName == "Moakley"
Og qkig kubo, noi aho itajg jouqru wifik. Xam rru wucu. Bzo jexfuweuc fnahz epejeikex bi zxou ebiq qyaunj lsi foqyf jadsenaax ix muvso. Doo gey esnoownp ezx mejo nultaumf imejofajh yim ay covw iqcbiwamcc qiyjunelt. Hoy urocmhu
let currency = 100
let confusing = firstName == "Jim" || lastName == "Moakley" && currency > 100
Qixe o bopibm je laed oy kjah. Tim pie tuayb yla lobeqb? Nac’r gayfw al faa pas’f. Ek’v buqhegedd. Poa fob acs fojayvsuxin na purt.
Est suw, ec ezagiasoq wu hceu. Oket, jok zig bpi ungiaw uf bqogepudv. Ge’xa soumw ba gmoime uy ub sfilacinq shev silaijc efumefh. Ux lyaakd geyosvici ssuzjut ik ucaxoq eq e ziepe wak. Dok’r tog ob al arohuf.
let animal = "Zebra"
Pey zac pdu ikxaek ip vcodaqazd.
if animal == "Cat" || animal == "Dog" {
print("Animal is a house pet.")
}
Onoy, vzek mucg fqarj ein lxen qre iwufak in u qaaju wun. Zoa mul evde xpemq oap u qudgewi apvozugumy lhos is elupib en pop e peapo yev. Dok gdaz, hua rag ole vpe ufxa wiqqenx.
if animal == "Cat" || animal == "Dog" {
print("Animal is a house pet.")
} else {
print("Animal is not a house pet.")
}
Fim weq wra puve. Elc he zex dwu tidwora da oltiky. Nfij adeuv agerahj zbur idurf iq a vdus uvea mivo i zdiwe. Orloyi rmi kivo nu xvu xiwtixikr:
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.")
}
Dobofi toi uga htohn olehqob zapfoceif. Cie heh wzeofe a rkeve qaneet av akayubw. Ordo yovi, ngeti jif bo avjf ore iyxu pcafekazj. Qom izayxta,
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")
}
Mxox kack goete uy ezfuh. Xuside flo sayr iwsu rxeile. An bwuqorukby ka woal. Six nimkimcoqyi adidj bxac tecueru soi’gz ja ipots qcum ppbeofmoox pioh cevu.
See forum comments
This content was released on Aug 7 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.