Programare swift Swift tutorial from tutorials point | Page 21

Swift 4 precedence prefix Protocol required right set Type unowned weak willSet Whitespaces A line containing only whitespace, possibly with a comment, is known as a blank line, and a Swift 4 compiler totally ignores it. Whitespace is the term used in Swift 4 to describe blanks, tabs, newline characters, and comments. Whitespaces separate one part of a statement from another and enable the compiler to identify where one element in a statement, such as int, ends and the next element begins. Therefore, in the following statement: var age there must be at least one whitespace character (usually a space) between var and age for the compiler to be able to distinguish them. On the other hand, in the following statement: int fruit = apples + oranges //get the total fruits no whitespace characters are necessary between fruit and =, or between = and apples, although you are free to include some for better readability. Space on both side of a operator should be equal, for eg. int fruit= apples +oranges int fruit = apples + oranges //is a wrong statement //is a Correct statement Literals A literal is the source code representation of a value of an integer, floating-point number, or string type. The following are examples of literals: 92 // Integer literal 4.24159 // Floating-point literal "Hello, World!" // String literal Printing in Swift To print anything in swift we have ‘ print ‘ keyword. print has three different properties. Items – Items to be printed Separator – separator between items 9