Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created September 8, 2023 08:42
Show Gist options
  • Save laevandus/ba2ea20bede60e6c66919e7f4849932e to your computer and use it in GitHub Desktop.
Save laevandus/ba2ea20bede60e6c66919e7f4849932e to your computer and use it in GitHub Desktop.
protocol FormSubmitting {
func submitForm(_ form: Form, validates: Bool, timeout: TimeInterval)
}
extension FormSubmitting {
func submitForm(_ form: Form,
validates: Bool = true,
timeout: TimeInterval = 60) {
self.submitForm(form, validates: validates, timeout: timeout)
}
}
class MyObject: FormSubmitting {
func submitForm(_ form: Form, validates: Bool, timeout: TimeInterval) {
print(#function, validates, timeout)
}
}
let object = MyObject()
object.submitForm(form)
// submitForm_ :validates: timeout:) true 60.0
object.submitForm(form, validates: false, timeout: 30)
// submitForm_: validates: timeout:) false 30.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment