sgo
sgo copied to clipboard
Assignment of optional var to non-optional value should unwrap it.
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