Skip to content

Instantly share code, notes, and snippets.

@aoberoi
Forked from christianselig/swift-existentials.swift
Last active October 9, 2024 20:17
Show Gist options
  • Save aoberoi/ecb57b2a8d196080d2c525622a5a863e to your computer and use it in GitHub Desktop.
Save aoberoi/ecb57b2a8d196080d2c525622a5a863e to your computer and use it in GitHub Desktop.
protocol P {
}
struct Q: P {}
struct MyWrapper {
let key: String
let value: any P
}
let point: Q? = nil
// 🛑 Value of optional type 'Q?' must be unwrapped to a value of type 'Q'
let wrapper = MyWrapper(key: "point", value: point)
if wrapper.value == nil {
print("nil value")
} else {
print("continue…")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment