Consider this code snippet
var foo: String? = nil let bar = foo as Any print(bar) // -> nil print(bar == nil) // -> false
This feels like it doesn’t make much sense.
bar is not optional in this case, and thus should never be nil, but it can be nil. Because
bar is not optional, you cannot utilize any of the unwrapping methods Swift provides (guard, if let, ??, !)
I understand the reasoning behind this, but it doesn’t feel like it fits with the rest of Swift’s type system and only works this way on a technicality.
In my opinion, either variables should need to be
Any? to be nil, or unwrapping methods should be enabled for variables of type