Re:The Next Step for Generics
by nurettin on Wednesday June 17, 2020 @04:52AM
(#23549277)
This doesn't sound right. Could you paste an example of a misuse of optional (for example: an unchecked unwrap) causing a compilation failure instead of a panic?
[ Parent
| on HN ]
In Swift `let x = things.first` won't compile but `let x = things.first ?? "empty"` and `let x = things.first!` will. Does that count?
(Probably mangled the Swift, doing this from memory)
My swift isn't good, but since you didn't specify a type for x, I think it should compile anyway. But if things is an empty array of T, first may return nil and x will be of type T?. If things is an array of optional, x will be of type T??