Skip to content

Instantly share code, notes, and snippets.

@patka817
Created March 2, 2020 11:11
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 patka817/1aee94abd725140e849aa947741c24a8 to your computer and use it in GitHub Desktop.
Save patka817/1aee94abd725140e849aa947741c24a8 to your computer and use it in GitHub Desktop.
Operator for optional assignment
infix operator ?= : AssignmentPrecedence
public func ?= <Value>(lhs: inout Value, rhs: Value?) {
if let rhs = rhs {
lhs = rhs
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment