What are inline closures in Swift?

Inline closures are closure expressions that are included directly as a part of method or function or variable without the need for accessing them through a intermediate variable. If they are part of function or method, then they don’t have to declare the type of parameters and return values explicitly as Swift can infer them from their function type. Single expression closures can implicitly return the result without using the return keyword. Swift also provides shorthand argument names for inline closures such as $0, $1,$2 etc…

Leave a Reply

%d bloggers like this: