2 ms·
In Swift nil is the value equivalent to Haskell's None so there is no distinction there which I think you are saying that there is in Scala. Swift does have "i
by josephlord 12y ago
In Swift nil is the value equivalent to Haskell's None so there is no distinction there which I think you are saying that there is in Scala.
Swift does have "implicitly unwrapped optionals" which you declare with "!":
var x:Int! = nil
rather than normal optional syntax of
var x:Int? = nil
It does weaken the type system and I would only make very limited use of it. I would only ever use it for properties that will not be nil after the initialiser has finished. Even though there is a way around the type system to do dangerous things I think it is still far better to have the type system there and to only work round it when absolutely necessary than to default to something much weaker. As I've mentioned elsewhere "!" is a code smell and I would use it rarely and audit those places heavily.