정의
- 매개변수로 함수 혹은 클로저를 받고 받았던 것을 반환하는 함수
- Sorted, Map, Filter, Reduce
func getName(_ name: String) -> String{
return "내 이름은 \(name)"
}
var getNameClosure: (String) -> String
func sayHello(getName: (String) -> String, name: String) -> String{
return getName(name)
}
let resultOne = sayHello(getName: getName(_:), name: "호롤롤로")
let numbers = [3, 7, 4, -2, 9, -6, 10, 1]
let stringNumbers : [String] = numbers.map{(aNumber: Int) -> [String] in
return "\(aNumber) 입니다."
}
let evens : [Int] = numbers.filter{ aNumber in
return aNumber % 2 == 0
}
let odds : [Int] = numbers.filter{ aNumber in
return aNumber % 2 != 0
}