Functions in Swift

The following is the syntax to declare a function.

Functions are self-contained chunks of code that perform a specific task. You give a function a name that identifies what it does, and this name is used to “call” the function to perform its task when needed. Functions can also be written within other functions to encapsulate useful functionality within a …