1. The most basic way to pass a function
2. Basic closure
3. Trailing closure
4. Forms that can be simplified
func backwards(first: String, second: String) -> Bool { print("\(first) \(second) 비교중") return first > second } let names = ["wizplan", "eric", "yagom", "jenny"] // Original let Original = names.sorted(by: backwards(first:second:)) // Basic closure let basicClosure: [String] = names.sorted(by: { (first: String, second: String) -> Bool in return first > second }) // Trailing closure 1 let trailingClosure = names.sorted() { (first: String, second: String) -> Bool in return first > second } // Parentheses can be omitted too let trailingClosure2 = names.sorted { (first: String, second: String) in return first > second } // Multiple trailing closures func multipleTrailing(a: (String) -> Void, b: (Int) -> Void, c: (Double) -> Int) {} let multipleTrailingClousure = multipleTrailing { (x: String) in // contents } b: { (x: Int) in // contents } c: { (x: Double) in // contents return 3 } // Simplifying closure expressions // Type inference let inferType = names.sorted { (first, second) in return first > second } // Shorthand arguments let shorthandArgument = names.sorted { return $0 > $1 } // Omitting the return type let implicitReturn = names.sorted { $0 > $1 } // Operator function let operatorFunction = names.sorted(by: >)