Skip to content

Instantly share code, notes, and snippets.

@mthouser
Last active August 29, 2015 14:15
Show Gist options
  • Save mthouser/677f89b5750b96d6fca5 to your computer and use it in GitHub Desktop.
Save mthouser/677f89b5750b96d6fca5 to your computer and use it in GitHub Desktop.
Swift Presentation: Closure Example
var names = ["Neil", "Tim", "Kiran"]
var reversed : [ String ]
reversed = sorted(names, { (s1: String, s2: String) -> Bool in
return s1 > s2
} )
reversed = sorted(names, { s1, s2 in s1 > s2 } )
reversed = sorted(names, { $0 > $1 } )
reversed = sorted(names, >)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment