- iOS Programming Cookbook
- Hossam Ghareeb
- 84字
- 2021-07-09 18:29:38
Inferring type
When closures are passed as argument like what we did in the sort function, Swift can infer the types of closure parameters and return type. In that case, we can omit the parameters and return types, as there is no need to write them. In our previous example, when we infer types, the sort function would be like this:
names.sort{ str1, str2 in return str1 > str2 }
As you can see, the String types and the return type have been omitted.
推薦閱讀
- 樂學(xué)Windows操作系統(tǒng)
- Windows Vista基礎(chǔ)與應(yīng)用精品教程
- 零起點(diǎn)學(xué)Linux系統(tǒng)管理
- Linux實(shí)戰(zhàn)
- Ganglia系統(tǒng)監(jiān)控
- SharePoint 2013 應(yīng)用開發(fā)實(shí)戰(zhàn)
- Windows Phone應(yīng)用程序開發(fā)
- 巧學(xué)活用Windows 7
- Learning Magento 2 Administration
- Learn CUDA Programming
- Linux操作系統(tǒng)
- Agile IT Security Implementation Methodology
- CSS揭秘
- Linux內(nèi)核修煉之道
- Learning Joomla! 3 Extension Development(Third Edition)