inout keyword is a powerful alternative to tuples for Swift and one thing to make a mistake.
PFB- Some notes worth considering
Sample:
PFB- Some notes worth considering
- When the function is called, the value of the argument is copied. (also known as copy-in copy-out or call by value result)
- In the body of the function, the copy is modified.
- When the function returns, the copy’s value is assigned to the original argument.
- In-out parameters cannot have default values.
- Variadic parameters cannot be marked as inout.
- We must use the ampersand "&" when passing arguments.
Sample:
/// inout
func check ( string: inout String) {
string = "Innova"
}
var string = "hello"
print(string)
check(string: &string)
print(string)