- Swift Functional Programming(Second Edition)
- Dr. Fatih Nayebi
- 117字
- 2021-07-02 23:54:33
Closures
Closures are great tools for FP as they are functions without the func keyword and name. Like functions, closures are self-contained blocks of code that provide a specific functionality and can be stored, passed around, and used in the code. Closures capture the constants and variables of the context in which they are defined. Although closures are the equivalent of blocks in Objective-C, they have a simpler syntax in Swift compared to the C and Objective-C block syntax. Nested functions, which we have covered in a previous section, are special cases of closures. Closures are reference types that can be stored as variables, constants, and type aliases. They can be passed to and returned from functions.
推薦閱讀
- 公有云容器化指南:騰訊云TKE實戰(zhàn)與應(yīng)用
- Python數(shù)據(jù)分析與挖掘?qū)崙?zhàn)
- Python絕技:運用Python成為頂級數(shù)據(jù)工程師
- 劍破冰山:Oracle開發(fā)藝術(shù)
- SQL Server 2008數(shù)據(jù)庫應(yīng)用技術(shù)(第二版)
- 一個64位操作系統(tǒng)的設(shè)計與實現(xiàn)
- gnuplot Cookbook
- 數(shù)據(jù)科學(xué)實戰(zhàn)指南
- 數(shù)據(jù)庫應(yīng)用系統(tǒng)開發(fā)實例
- 云計算寶典:技術(shù)與實踐
- 數(shù)據(jù)指標(biāo)體系:構(gòu)建方法與應(yīng)用實踐
- 企業(yè)級大數(shù)據(jù)項目實戰(zhàn):用戶搜索行為分析系統(tǒng)從0到1
- ORACLE 11g權(quán)威指南
- Oracle 11g數(shù)據(jù)庫系統(tǒng)設(shè)計、開發(fā)、管理與應(yīng)用
- Unity iOS Essentials