Skip to content

Instantly share code, notes, and snippets.

@nverinaud
Created April 1, 2020 05:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nverinaud/a31624a05924b623224fb686fd7bfde3 to your computer and use it in GitHub Desktop.
Save nverinaud/a31624a05924b623224fb686fd7bfde3 to your computer and use it in GitHub Desktop.
Swift Kotlinified : Optional.let
extension Optional {
func `let`(_ action: (Wrapped) -> ()) {
if let value = self {
action(value)
}
}
}
// Usage
func stopObserving(_ observer: Any?) {
observer.let(notificationCenter.removeObserver)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment