Created
August 9, 2018 13:05
-
-
Save jonathanduty/4ed92d7f7d54eb4d78399d7e08c113aa to your computer and use it in GitHub Desktop.
Option operator for assigning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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