Swift Tutorial - Tutorialspoint
|| Called Logical OR Operator. If any of the two operands is non-zero, then the condition becomes true. (A || B) is true. ! Call ...
Bitwise operators supported by Swift language are listed in the following table. Assume variable A holds 60 and variable B holds ...
/= Divide AND assignment operator, It divides left operand with the right operand and assigns the result to left operand C /= A ...
Operators Precedence Operator precedence determines the grouping of terms in an expression. This affects how an expression is ev ...
Decision making structures require that the programmer specifies one or more conditions to be evaluated or tested by the program ...
nested if statements You can use one if or else if statement inside another if or else if statement(s). switch statement A^ swit ...
Example import Cocoa var varA:Int = 10 ; /* Check the boolean condition using if statement */ if varA < 20 { /* If condition ...
Flow Diagram Example var varA:Int = 100 ; /* Check the boolean condition using if statement */ if varA < 20 { /* If condition ...
An if can have zero or one else's and it must come after any else if's. An if can have zero to many else if's and they must ...
When the above code is compiled and executed, it produces the following result: None of the values is matching Value of variable ...
println("Value of variable varB is \(varB)"); When the above code is compiled and executed, it produces the following result: Fi ...
statement(s) fallthrough /* optional */ default : /* Optional */ statement(s); } If we do not use fallthrough statement, then th ...
import Cocoa var index = 10 switch index { case 100 : println( "Value of index is 100") fallthrough case 10 , 15 : println( "Val ...
There may be a situation when you need to execute a block of code several number of times. In general, statements are executed s ...
do...while loop Like a while statement, except that it tests the condition at the end of the loop body. for-in Loop The for-in l ...
Example import Cocoa var someInts:[Int] = [ 10 , 20 , 30 ] for index in someInts { println( "Value of index is \(index)") } When ...
Flow Diagram Example import Cocoa var someInts:[Int] = [ 10 , 20 , 30 ] for var index = 0 ; index < 3 ; ++index { println( "V ...
Swift – while Loop A while loop statement in Swift programming language repeatedly executes a target statement as long as a give ...
The key point of a while loop is that the loop might not ever run. When the condition is tested and the result is false, the loo ...
Syntax The syntax of a do...while loop in Swift is: do { statement(s); }while( condition ); It should be noted that the conditio ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf