Created
June 29, 2016 15:59
-
-
Save adamnemecek/7e3802df3d8f890fc8f8a83469c22d4f to your computer and use it in GitHub Desktop.
Swift coalescing assignment operator
This file contains 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
infix operator ??= { | |
associativity right | |
precedence 90 | |
assignment | |
} | |
func ??=<T>(inout optional: T?, @autoclosure defaultValue: () -> T?) { | |
optional = optional ?? defaultValue() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment