I am currently learn the use of generic functions and realized the problem that they solve with some existing examples in the documentation.
So instead I keep repeating functions that perform the same scheme, I can use generic functions that way:
func swapTwoValues<T>(inout a: T, inout b: T) {
let temporaryA = a
a = b
b = temporaryA
}
But if we think a little more we can use the command Any for that:
func swapTwoStrings(inout a: Any, inout b: Any) {
let temporaryA = a
a = b
b = temporaryA
}
So, why use generic functions if we can do the job using Any?