Why can you not bind if expressions?

All of these generate the error

switch if true { 1 } else { nil } {
default: return
}
guard let value = if true { 1 } else { nil } else { return }
if case .some(let value) = if true { 1 } else { nil } { }

(Enclosing parentheses do not help.)


true ? 1 : nil works fine in all cases.

I'm afraid support of "full expressions" was left as a future direction.

1 Like