4. Conditionals
Conditionals in Swift are used to make decisions in your code. They allow us to make different decisions based on the different circumstances. The condition is an expression that evaluates to a Boolean value, which can be either true or false. If the condition is true, the corresponding code block will execute; if false, that particular block won't execute. You can define a separate code block to execute if the condition is false.
There are three types of conditionals in Swift:
ifstatementsif-elsestatementsswitchstatements
Last updated
Was this helpful?