Lazy Properties

A lazy property is a property whose initial value is not calculated until the first time it is accessed.

TypeAlias

A typealias is used to provide an alternative name for an existing type. It helps improve code readability, especially when working with complex or verbose types. It does not create a new type; it only creates a new name for an existing type.

Defer

defer is a statement used to execute a block of code just before the current scope e.g a function or loop exits.

Higher Order Functions

Higher-order functions are widely used for functional programming. Swift provides many built-in higher-order functions such as map, filter, reduce, and compactMap 1. map The map function transforms each element in a collection by applying a closure. 2. filter The filter function filters elements of a collection based on a condition. …

Associated Type(Generics in Protocol)

Associated types are placeholders that a protocol defines for the type it expects. The actual type is specified when a protocol is adopted. This allows the protocol to work generically with any type. Advantages of Associatedtype Realtime Example Using in API call