O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining and using function parameters

In function definition, parameters follow the function name and they are constants by default so we will not be able to alter them inside the function body.

Parameters should be inside parentheses. If we do not have any parameters, we simply put open and close parentheses without any characters between them as follows:

func functionName() { } 

In FP, it is important to have functions that have at least one parameter. Remember, a function in mathematics is a relation between a set of inputs and outputs. So, we always have at least an input in a function and the same principle applies to FP.

As you'll already know or have guessed, we can have multiple parameters in function definition. Parameters are ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required