The function of autoclosure according to Swift docs states that
An autoclosure is a closure that is automatically created to wrap an expression that’s being passed as an argument to a function. It doesn’t take any arguments, and when it’s called, it returns the value of the expression that’s wrapped inside of it.
But when i create a function that takes autoclosure
func test(_ clsr:@autoclosure(String)->(String)){
let res = clsr("Hello World")
print(res)
}
test("Good Morning")
Even the syntax is valid and i can pass the value i cannot use the String value inside the statement. So, is this something swift is missing. May be it should show some error warning while defining the Arguments.
Or am i missing something about autoclosures?