Skip to content

Instantly share code, notes, and snippets.

@adam-rocska
Last active March 30, 2022 13:25
Show Gist options
  • Save adam-rocska/9f7c23f52bd5fca7728b7a2278eef6d5 to your computer and use it in GitHub Desktop.
Save adam-rocska/9f7c23f52bd5fca7728b7a2278eef6d5 to your computer and use it in GitHub Desktop.
A Swift operator unwrapping & returning an optional value if it exists, while throwing an error if it doesn't.
// TODO: Depend on https://github.com/21GramConsulting/Beton instead
@adam-rocska
Copy link
Author

Example usage:

let which = URL(fileURLWithPath: try await standardOutput(of: env, "which", "which") ?! Error.failure)

@adam-rocska
Copy link
Author

Go and depend on https://github.com/21GramConsulting/Beton To use this operator & many similar ones. We’ll shovel our things in one big pile of goodies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment