Created
November 10, 2022 19:11
-
-
Save hmlongco/2fe49fd5e458955ec21bfa8d914c1a42 to your computer and use it in GitHub Desktop.
Binding+defaultValue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Binding { | |
public func defaultValue<T>(_ value: T) -> Binding<T> where Value == Optional<T> { | |
Binding<T> { | |
wrappedValue ?? value | |
} set: { | |
wrappedValue = $0 | |
} | |
} | |
} |
Author
hmlongco
commented
Nov 10, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment