iOS Programming Cookbook
上QQ阅读APP看书,第一时间看更新

Omitting the return keyword

Swift can make your life easier than that. When closure body consists of only one expression, the return keyword can be omitted. So, the new version of sort function will be like this:

names.sort({ str1, str2 in str1 > str2})