About if value != nil
, it is really problematic. Currently this code works.
var value: Int? = 42
// some process
if value != nil {
// some process
// finally make value nil
value = nil
}
If Swift introduces if value != nil
that implicitly unwraps value
, it starts causing error, because value
inside if
is no longer Int?
but Int
. It's source breaking change actually.
(EDIT)
About this smart cast, type guard, or 'inference', we did further discussion. If you have any objection about this, please check the link below.