0 votes
in Swift by
What is the use of double question mark “??” in swift?

1 Answer

0 votes
by

The double question mark “??” is a nil-coalescing operator, it is mainly a shorthand for the ternary conditional operator where we used to test for nil. A double question mark is also used to provide a default value for a variable.

stringVar ?? “default string”

This exactly does the common thing, if stringVar is not nil then it is returned, otherwise the “default string” is returned.

...