|
|
|
|
|
by filwit
4067 days ago
|
|
You prove to the compiler that the nilable var is not-nil via if statement. Eg: proc foobar(f:Foo not nil) =
discard
let f = Foo() # nilable ref
let b: Foo not nil = f # Error, can't prove 'f' is not nil
if f != nil:
let b: Foo not nil = f # can assign non-nil vars to 'f'
foobar(f) # or can pass 'f' directly
|
|
Might be a good example for http://nim-lang.org/manual.html#not-nil-annotation