Define generics in Swift?

Define generics in Swift?

Generics are one of the most powerful features of Swift, as it is a way of making one data type act in a variety of ways depending on how it is created. Hence, enables you to write flexible, reusable functions and types that can work with any type. You can write code that avoids duplication by using generics in most cases.

For example, Swift’s Array and Dictionary types are both generic collections. You can create an array that holds Int values, or String values, or indeed an array for any other type that can be created in Swift.