Swift Programming Tutorial: Functions

Photo by: Wes Hicks at unsplash.com

A function is a reusable code containing set of instructions that performs specific outcome. The primary goal of using a function is to avoid writing the same block of code with the same purpose multiple times. Function is also called method in object oriented programming.

In Swift, we declare functions by using func.

E.g.