Last active
November 6, 2018 02:53
-
-
Save dmlebron/db6c1d92d2e002ed11f2deea7c0f8414 to your computer and use it in GitHub Desktop.
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
struct MyObject { | |
var myProperty: String? | |
} | |
extension Optional where Wrapped == MyObject { | |
var unwrappedOrInit: MyObject { | |
switch self { | |
case .some(let unwrapped): | |
return unwrapped | |
case .none: | |
return MyObject() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment