Skip to content

Instantly share code, notes, and snippets.

@jonathanduty
Created August 9, 2018 13:05
Show Gist options
  • Save jonathanduty/4ed92d7f7d54eb4d78399d7e08c113aa to your computer and use it in GitHub Desktop.
Save jonathanduty/4ed92d7f7d54eb4d78399d7e08c113aa to your computer and use it in GitHub Desktop.
Option operator for assigning
/// Optional Assignment, assigns if value exists
infix operator ?=: AssignmentPrecedence
func ?=<T>(lhs: inout T, rhs: T?) {
guard let value = rhs else { return }
lhs = value
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment