swift - about entertainment

let array = ["one", "two", "three", "four", "five"]
// the old version: no closure before the abbreviation 
var result = Sort (Array, {(S1: String, S2: String) -> Bool in  return S1 < S2})
 // old version: the ultimate closure abbreviation 
result = sort (array, <)
{(S1: String, S2: String) -> Bool in return S1 < S2} == <    
might not seem very magical, the code is not Si Si is wonderful, with a long list of character strings to get.
Array = var [ " One " , " TWO " , " Three " , " Four " , " Five " ]
 // Now: Abbreviation not before closure 
array.sort (by: {(s1: String, s2: String) -> Bool in  return S1 < S2})
 // now: Abbreviation ultimate closure after 
Array.sort () {$ 0 <$ . 1 }

 

 

Guess you like

Origin www.cnblogs.com/sheer-code/p/11027687.html