Files
the-swift-programming-langu…/source/chapter2/Closures.md
2014-06-05 11:20:36 +08:00

7 lines
444 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 闭包
闭包是功能性自包含模块可以在代码中被传递和使用。Swift 中的闭包与 C 和 Objective-C 中的 `blocks` 以及 其他一些编程语言中的 `lambdas` 比较相似。
闭包可以 **capture** 和存储其所在上下文中任意常量和变量的引用。这就是所谓的闭合并包裹着这些常量和变量俗称闭包。Swift 会为您管理在 **capture** 过程中涉及到的内存操作。