optional array in swift code example
Example 1: swift declare optional values
// Optional values are types that can contain nil
var optionalValue: String? // this can be done with more than strings, but for this example that's what was used
Example 2: how to unwrap arrays with optional value in swift
let arrayOfOptionals: [String?] = ["Seems", "like", "an", nil, "of", "optionals"]
let arrayWithNoOptionals = arrayOfOptionals.compactMap { $0 }