Structures and Classes: How are structures different ? No inheritance. No type casting to check at runtime. No reference counting. No multiple references. No deinitializers. Structures are value types. When you assign instance of a struct to another variable, the entire structure is COPIED and not REFERENCED. Classes instead are REFERENCE types, pointing to the same instance. === operator is to know if two variables / constants refer to the same instance. == means they are equal in some value. It is your responsibility to implement == and != in your class.
Closures: 1. These are self contained blocks of code that can be passed around in the code. Declare: (parameters) -> return Define: { ( parameters ) -> return type in // executable statements } reversedNames = names . sorted ( by : { ( s1 : String , s2 : String ) -> Bool in return s1 > s2 } ) 1. Inferring type from context reversedNames = names . sorted ( by : { s1 , s2 in return s1 > s2 } ) 2. Implicit returns from Single-expression closures reversedNames = names . sorted ( by : { s1 , s2 in s1 > s2 } ) 3. Short hand argument names. Can omit variable name, return and in key word as well. reversedNames = names . sorted ( by : { $0 > $1 } ) 4. Operator methods. Simply use the operator. reversedNames = names . sorted ( by : >) 5.Trailing closures. If closure is the final argument of a function, it can be passed as a trailing closure. func...