This should work:
var x ?X
x = X{...}
// x has type X now
Right now you're forced to do this:
var x ?X
x = X{...}
if x != nil {
// x has type X now
}
But the compiler could figure out that x is not nil there.
Be careful with this, though:
var x ?X
x = X{...}
// x has type X now
if something {
x = nil
}
// x should have type ?X again now
This should work:
Right now you're forced to do this:
But the compiler could figure out that
xis not nil there.Be careful with this, though: