Skip to content

Instantly share code, notes, and snippets.

@P0ed
Created February 2, 2017 08:59
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 P0ed/9ff76c4a1a532b77afb0f4dd1c4be40b to your computer and use it in GitHub Desktop.
Save P0ed/9ff76c4a1a532b77afb0f4dd1c4be40b to your computer and use it in GitHub Desktop.
infix operator ?= : AssignmentPrecedence
func ?= <A>(lhs: inout A, rhs: A?) {
if let value = rhs {
lhs = value
}
}
func ?= <A>(lhs: inout A?, rhs: A?) {
if let value = rhs {
lhs = .some(value)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment