๐ฐclosure
Swift โฉ type โฉ basic types โฉ closure
Closures are functions that run in place, without the need for a name. Closures can capture and store references to any constants and variables from the context in which they are defined. This is known as closing over those constants and variables.
The parameters in closure expression canโt have a default value.
Closures take one of three forms:
Global functions๏ผ have a name and donโt capture any values.
Nested functions๏ผ have a name and can capture values from their enclosing function.
closure expression๏ผ unnamed, can capture values from their surrounding context.
๐ see๏ผClosures
Last updated