inout variables swift – how it works ?

By | July 29, 2016

inout variables swift – how it works ?

Swift function parameters are by default constant type. That means you can not change parameter value inside the function body. In such case, if you need to change values then use inout keyword before the parameters. To understand this, let’s see below example of swapping to values :

While calling the function parameters must be passed using “&” sign before them. It looks similar to pass by reference concept.