官术网_书友最值得收藏!

How to do it...

  1. Go to Xcode and create a new playground file called Closures to test code about closures in it.
  2. To see closures in action, copy and paste this piece of code in the playground file (the output of each statement is printed on the right):
      var names = ["David", "Jones", "Suzan", "Naomi", "Adam"] 
 
      names.sort() // ["Adam", "David", "Jones", "Naomi", "Suzan"] 
      names.sort{ (str1: String, str2: String) ->Bool in 
        return str1 > str2 
      } 
 
      // ["Suzan", "Naomi", "Jones", "David", "Adam"] 
主站蜘蛛池模板: 佛学| 鄂州市| 温宿县| 甘洛县| 永年县| 淮南市| 茂名市| 台北县| 高要市| 榕江县| 五家渠市| 中牟县| 东源县| 同德县| 博野县| 健康| 永福县| 三穗县| 英山县| 卓尼县| 台东县| 文山县| 苍溪县| 新密市| 孙吴县| 怀柔区| 香港| 古交市| 定结县| 新田县| 右玉县| 北辰区| 仙居县| 周至县| 浦城县| 裕民县| 延吉市| 昌吉市| 潜山县| 达孜县| 廊坊市|