Skip to content

Why does addTextField's configuration closure parameter is Optional? #20

@Skogetroll

Description

@Skogetroll

The code is:

open func addTextField(_ configuration: (_ textField: UITextField?) -> ()) {
    let textField = EMAlertTextField()
    textField.delegate = self
    configuration(textField)
    addTextField(textField)
}

EMAlertTextField.init is not optional constructor. So textField guaranteed to be non-optional.

There's no way call like configuration(nil) ever happen.

So why does it still declared as configuration: (_ textField: UITextField?) -> ()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions