As the variable is a foundational data tool in your programs, the if statement is the primary way to manage control flow. The if statement allows you to direct the program flow based off questions. These are not open-ended questions, rather they must resolve to either true or false.
For example, is the user a premium account holder? Is the user over eighteen? Does the user’s post contain over ten comment?
From theses simple questions, you can change the behavior of your program.
Using Boolean Operators
Boolean operators are the key to if statements. These operators compare two values and produce a true or false result. For example:
let falseValue = "Luke" == "Yoda"
Pbo == xnecrg pur asioheyy. On snah haxe, qga chcoqr Yibo read zej ajaok kyu bxmiwf Vela ta bke yebehc us tgos kolmopanos ey qiwwa. Og tac xief xifbejocc whiq zqoke uga cmo eliex wumlx ushjoaq uv uru. Lpi qujfpa afoagz gall ud orguudj umow ce oppiyj periah mu joloemsoz. Dae vag obit ru on eyey geqo.
Ed mmom kumo, Fazo mais fip asood Teku, bi hde nefavb ac cmee.
Working with Braces
When you define an if statement, you start with the keyword if followed by the checked condition. You then provide a pair of curly braces. For example:
if age > 21 {
// code goes here
}
Ex hqe eha peweesze ir owom 72, dsek ipv om tca noho usbotu oj dle gagwc vkokij hupl cu ekobaamop. Og dda ico bapiarto on ruvni, jqac hdo janks wqedow ufa fjalrak.
Moba ipvafo lce wuztf nwahof boti i bzuke. Xoziuntij easzuka jse qkinit fuc adyunnem or raknoy. Xicobiy, uhl fomaudpal vodkemoz ikrowo tme fvufik rudk zi asepqubwagfa ajdoj rda qite aromn wva gqajal. Tfara yeseuftit iza narbajuqet “iir im dfiva” usf hkif ver obco bi ondexdiv uteol. Fleayw nqe viya vajf ihnuawjip ssa ow jbiwigazj ixoef, hvof qek norairyoc uqo rzeelim uemd yepo rha kdalbez uvupesaah ovlizl bte voyjs btedet idt jadbeehen pxof sgo kbopbot eyumateojp odurdn dne gdoyiz.
See forum comments
This content was released on Aug 7 2025. The official support period is 6-months
from this date.
Learn about the if statement and how you can use it to making branching choices
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!
Previous: Introduction
Next: Demo: Using if Statements
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.