
	                	                 
`with` 메서드의 인자 `action`으로 `printHello` 함수를 넘겨야 하는 경우, 다음과 같이 작성할 수 있습니다.
#hostingforum.kr
swift
extension String {
    func with(_ action: () -> Void) -> String {
        action()
        return self
    }
}
func printHello() {
    print("Hello, World!")
}
print("Hello".with { printHello() })
위 코드에서, `with` 메서드의 인자 `action`으로 `printHello` 함수를 넘겨야 하는 경우, 클로저를 사용하여 함수의 인자를 넘길 수 있습니다.
#hostingforum.kr
swift
print("Hello".with { printHello() })
위 코드에서, `with` 메서드의 인자 `action`으로 클로저를 넘겨서 `printHello` 함수를 호출합니다.
또는, `with` 메서드의 인자 `action`으로 함수의 이름을 넘겨서 함수를 호출할 수도 있습니다.
#hostingforum.kr
swift
print("Hello".with(printHello))
위 코드에서, `with` 메서드의 인자 `action`으로 `printHello` 함수의 이름을 넘겨서 함수를 호출합니다.
이러한 방법으로, 함수의 인자를 넘겨서 함수를 호출할 수 있습니다.
2025-03-17 00:57