Nulls

From Adam Colton
Revision as of 19:22, 17 September 2019 by Adamcolton (talk | contribs) (Created page with "Because we don't have null, we need null. type Null union < Elem interface{} > [ Null struct{} Value Elem ] var foo Null<int> = Foo() if foo.Null? { ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Because we don't have null, we need null.

 type Null union <
   Elem interface{}
 > [
   Null struct{}
   Value Elem
 ]
 
 var foo Null<int> = Foo()
 if foo.Null? {
   return foo
 }
 // at this point, the compiler knows that foo must be case Value
 // so in this instance, i now has a type of int
 return i*20