ios - what's the purpose of double question mark in swift -


this question has answer here:

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

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -