Created
May 2, 2017 06:36
-
-
Save efremidze/0405d73e6683a29da263688b3207c29a to your computer and use it in GitHub Desktop.
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
extension Dictionary { | |
subscript(key: Key, `default` value: Value) -> Value { | |
mutating get { | |
return self[key] ?? { | |
self[key] = value | |
return value | |
}() | |
} | |
set { self[key] = newValue } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment