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

Associated Type in Swift

Associated Type in Swift In Swift, an associated type is a placeholder name for a type that is used as part of the protocol. The actual type to be used for the associated type is not specified until the protocol is adopted. Associated types are often used to specify the type of values that a …

Spread the love