Is there a possibility to only perform an assignment (e.g. to a non-optional property) if the right hand side is not nil? I am looking for a one-line form for:
The answer from @Sajjon could be improved by using an if let to avoid reflection.
precedencegroup OptionalAssignment { associativity: right }
infix operator ?= : OptionalAssignment
public func ?= (variable: inout T, value: T?) {
if let value = value {
variable = value
}
}