An optional var defaults to nil (p1
), but not when its type is Optional
(like p3
)
struct Demo {
var p1: String? // defaults to `nil`
let p2: String? // compiler error
var p3: Optional<String> // compiler error
let p4: Optional<String> // compiler error
}