One In Swift language If the Boolean expression is When the above code is compiled and executed, it produces the following results:
if
a statement consists of a Boolean expression followed by one or more statements. 9.11.1. Grammar #
if
syntax of the statement:if boolean_expression {
/* The statement to be executed if the Boolean expression is true */
}
true
, then
if
the block of code within the statement will be executed. If the Boolean expression is
false
, then
if
the first set of code at the end of the statement (after closing parentheses) is executed. 9.11.2. Flow chart #

9.11.3. Example #
import Cocoa
var varA:Int = 10;
/* detected condition */
if varA < 20 {
/* If the conditional statement is true, execute the following program */
print("VarA < 20");
}
print("The value of the varA variable is \(varA)");
varA < 20
The value of the varA variable is 10