The actual type to use in place of T will be determined each time the swapTwoValues(::) function is called.
You can provide more than one type parameter by writing multiple type parameter names within the angle brackets, separated by commas.
Always give type parameters upper camel case names (such as T and MyTypeParameter) to indicate that they are a placeholder for a type, not a value.
In addition to generic functions, Swift enables you to define your own generic types. These are custom classes, structures, and enumerations that can work with any type, in a similar way to
Because it is a generic type,
Stack can be used to create a stack of any valid type in Swift, in a similar manner to
When extending a generic type, you do not provide a type parameter list but use the same from the original type definition:
An associated type gives a placeholder name to a type that is used as part of the protocol.
And in the class/struct that conforms to the
A generic where clause enables you to require that an associated type must conform to a certain protocol, or that certain type parameters and associated types must be the same: