Last active
March 12, 2017 01:09
-
-
Save efremidze/1f67ae9955d6040cf29c4943433bf1a1 to your computer and use it in GitHub Desktop.
unwrap shortcut
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 Optional { | |
func unwrap(_ f: (Wrapped) -> Void) { | |
_ = self.map(f) | |
} | |
} | |
// usage: | |
// let username: String? | |
// username.unwrap { user.username = $0 } // update user if username exists |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment