On Xcode 10.1
, the following statement wasn't having any issues, but after updating the Xcode
to 10.2
compiler is generating warning for the statement.
return [
"sublevels": (self.sublevels?.array ?? [Sublevel]()) as NSObject
]
sublevels
is NSOrderedSet
, and the warning generated is as follows:
Left side of nil coalescing operator '??' has non-optional type '[Any]?', so the right side is never used
But if I break the single statement as follows, the warning disappears.
let sublevels = self.sublevels?.array ?? [Sublevel]()
return [
"sublevels": sublevels as NSObject
]
Please, will anyone explain - what is the issue with the first statement ?