function1 Swift _ Functions 특정 기능을 수행하는 코드 조각 장점 Reusability _ 불필요한 코드 반복을 방지 특징 - 코드 내에서 함수 표기 시에는 괄호를 빼거나 argument label만 표기 //예제1 func printHello(with name: String) { print("hello, \(name)") } let f2: (String) -> ( ) = printHello(with:) let f3 = printHello(with:) f3("World") // hello, World //예제2 func add(a: Int, b: Int) -> Int{ return a + b } var f4: (Int, Int) -> Int = add(a:b:) f4(1, 2) // 3 - first class citizen 변수와.. 2022. 10. 3. 이전 1 다음 반응형