Your Second iOS and SwiftUI App · Section Headers |

This is a companion discussion topic for the original entry at

@jessycatterwaul, what is the difference between implementing closure with type “()->_” like of Section() and “()->()” like of many others?

The underscore is a generic placeholder for a specific type. () is the same thing as Void, so when you write closures with the () -> () type signature, they won’t return anything.

If that doesn’t make enough sense yet, you can learn more about generics in the Advanced Swift course.

1 Like