~evanj/zan

f7c9bc1ff9024c367186b8205289a48de187dd03 — Evan M Jones 6 months ago ade3c9e master
Feat(ex): Refining example.
1 files changed, 26 insertions(+), 0 deletions(-)

A examples/lib/lib.z
A examples/lib/lib.z => examples/lib/lib.z +26 -0
@@ 0,0 1,26 @@
pkg lib // Similar to Go's `package`

use [ // To use other libraries, similar to Go's `import`.
  io 
]

type thinger [ // Notice no `struct` or `interface`. 
  string name // Private property.
]

fn new [ string val ] thinger [ // Factory func.
  ret thinger [ name val ]
]

fn thinger greet [] string [ // Private method.
  ret io.sprint [ "hi my name is" thinger.name ]
]

fn thinger print [] [ // Public method.
  io.print [ thinger.greet[] ]
]

give [ // To export types, type properties, functions, and methods. 
  lib.new
  lib.print
]