​Fast is just a strong and spontaneous programming language for macOS, iOS, watchOS and tvOS....

Page 48

Swift

Flow Diagram

Example var varA:Int = 100;

/* Check the boolean condition using if statement */ if varA < 20 { /* If condition is true then print the following */ println("varA is less than 20"); } else { /* If condition is false then print the following */ println("varA is not less than 20"); } println("Value of variable varA is \(varA)"); When the above code is compiled and executed, it produces the following result: varA is not less than 20 Value of variable varA is 100

if...else if...else Statement An if statement can be followed by an optional else if...else statement, which is very useful to test various conditions using single if...else if statement. When using if, else if, else statements, there are a few points to keep in mind. 36


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.