ios - what's the purpose of double question mark in swift -
this question has answer here:
- ?? operator in swift 4 answers
i have seen such function:
public func highlightvalues(highs: [charthighlight]?) { // set indices highlight _indicestohightlight = highs ?? [charthighlight](); // redraw chart setneedsdisplay(); } what's purpose of ?? here? searched, seems searching ?? hard find proper answer.
it called nil coalescing operator. if highs not nil unwrapped , value returned. if nil [charthighlight]() returned. way give default value when optional nil.
Comments
Post a Comment