Generic in Swift

Generic in Swift In the Swift programming language, the term “generic” refers to a type or function that can work with any type, rather than being tied to a specific type. This allows for greater flexibility and code reuse. For example, a generic function can be written to sort an array of any type, rather …

Spread the love

Extensions in Swift

Extensions in Swift In Swift, an extension is a way to add new functionality to an existing class, structure, enumeration, or protocol type. This can include adding new methods, computed properties, and initializers, as well as providing new implementations of existing methods, properties, and subscripts. Extensions can be used to extend the functionality of any …

Spread the love

Subscript in Swift

Subscript in Swift By implementing Subscript we can set and retrieve structure value by index (associative array or dictionary style) without separate methods for setting and retrieval. Classes and Enumerations can define subscripts too. For example, I want to build an Address struct that can hold different string values. A contact can have a present …

Spread the love