Swift - Function Function Creation

Introduction

In Swift, a function is defined using the func keyword, like this:

func myFunction() {
   print("myFunction")
}

Here, the code defines a function called myFunction.

It does not take in any inputs (parameters) and does not return a value.

Technically it does return a Void value.

To call the function, call its name followed by a pair of empty parentheses:

myFunction()

Related Topic