Last updated on September 25, 2019
The dictionary term of boolean denotes as “a binary variable that can have one of two possible values, 0 (false) or 1 (true).” Basically, booleans is either true or false and is also referred as logical because they are either true or false.
The best thing about a boolean is even if you are wrong, you are only off by a bit.
Annoymous
In this tutorial, you’ll learn what is boolean. You’ll learn:
- The basic of boolean.
Prerequisites
To follow along this tutorial, you’ll need some basic knowledge in:
- Basic familiarity in Swift.
- At least Xcode 7.1.
Basic of Boolean
Boolean is particularly useful when it comes to conditional statement such as the if statement.
1 2 3 4 5 6 7 8 9 |
let delicious = true if delicious { print("Mmmmmm...") } else { print("Yuckk") } // Mmmmmm... |
The code above basically means we have created a variable by storing a boolean value of true and if it is true, print “Mmmmmm…”
Where to go From Here
If you feel like you are ready to take on more challenges, feel free to check out some other tutorials that we have created:
Be First to Comment