카테고리 없음
Swift - Closure
func calculator (n1: Int, n2:Int, operator : (Int, Int) -> Int) -> Int return operator(n1,n2) } let result = calculator(n1:2, n2:3) {$0 * $1} print(result) func multiply (no1:Int, no2:Int) -> Int { return no1 * no2 } calculator(n1:2, n2:3, operation: multiply) 간소화 예제 calculator(n1:2, n2:3, operation: multiply) calculator(n1:2, n2:3, operation: {(no1:Int, no2:Int) -> Int in no1 * no2 }) calculato..
2021. 12. 3. 16:34