What is the purpose of a double question mark in quick

I saw a function like this:

public func highlightValues(highs: [ChartHighlight]?) { // set the indices to highlight _indicesToHightlight = highs ?? [ChartHighlight](); // redraw the chart setNeedsDisplay(); } 

What is the purpose ?? here? I searched, but it looks like a search ?? hard to find the right answer.

+47
ios swift
Jun 15 '15 at 3:51 on
source share
1 answer

It is called a nil-coalescing operator. If highs not nil , than it is deployed, but the return value. If it is zero, [ChartHighlight]() returned. This is a way to give a default value if nil optional.

+81
Jun 15 '15 at 3:55
source share



All Articles