Swift: Functions

Functions are self-contained block of code that perform a specific task. We give names to functions to call them later.Name given to functions should reflect what the function does on call. Just like any other function types, Swift functions may or may not have parameters. The parameters may also include default values and can update the value of the entity passed through them after the function execution(inout parameters). Every function in Swift has a type which consists of parameter types and return type. We can pass functions as parameters to another function and can return functions from functions.

Leave a Reply