?? operator in Swift

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.

Leave a Comment