It is “nil coalescing operator” (also called “default operator”). a ?? b
is value of a
(i.e. a!
), unless a
is nil
, in which case it yields b
. I.e. if favouriteSnacks[person]
is missing, return assign "Candy Bar"
in its stead.
More Related Contents:
- How to get the indexpath.row when an element is activated?
- How do I check when a UITextField changes?
- Conditional Binding: if let error – Initializer for conditional binding must have Optional type
- Find out if Character in String is emoji?
- How do I add text to an image in iOS Swift?
- How to detect if app is being built for device or simulator in Swift
- How do I write dispatch_after GCD in Swift 3, 4, and 5?
- How to recognize swipe in all 4 directions
- Drop-Down List in UITableView in iOS
- Drawing class drawing straight lines instead of curved lines
- Static Library and Swift
- How do I save a UIColor with UserDefaults? [duplicate]
- How do I create a new Swift project without using Storyboards?
- Linker Error in iOS (duplicate symbols for architecture x86_64)
- Remove objects with duplicate properties from Swift array
- Upload image with multipart form-data iOS in Swift
- UITableViewCell Buttons with action
- Swift UIColor initializer – compiler error only when targeting iPhone5s
- Add swipe to delete UITableViewCell
- How can I programmatically find Swift’s version?
- How I can implement Login / Logout Navigation using UserDefaults in swift?
- Blocks on Swift (animateWithDuration:animations:completion:)
- iOS – ‘MyProject-Swift.h’ file not found when running Unit Tests for Swift
- How to present view controller from right to left in iOS using Swift
- How shouldChangeCharactersInRange works in Swift?
- Facebook Graph API GET request – Should contain “fields” parameter (Swift, Facebook SDK v4.5.1)
- How To Get HTML source from URL with Swift
- How to get the front camera in Swift?
- Pass multiple parameters to addTarget
- Working with Live Photos in Playground