Read about the in-out parameters in Swift functions and find out how to mutate provided arguments if necessary inside functions.
Higher Order Functions in Swift – An Introduction
What exactly are higher order functions in Swift? This post explains that, and it goes one step further by showing how to create your own.