Should Swift allow @escaping on uninitiated closure member var?

I was hoping I can do this:

struct FooButton: View {
    let action: @escaping () -> Void
    .....
}

and use the default member wise initializer. Is this a good idea? or not for Swift to have?

Is action already @escaping by the fact that it's a member var retaining the value set by the call in default init?

Yes, fields can only hold “escaped” function values.

1 Like
Terms of Service

Privacy Policy

Cookie Policy