Functions and types
Functions and types
Functions, your own types, traits, and programs of several files.
fn name(x: int): str { … }, return, several results q: int, r: int = divide(7, 2), one-line fn add(a: int, b: int): int => a + b, defaults greeting: str = "Hello", lambdas nums.map(fn(n) => n * 2)
your own types, obj Person { name: str … }, methods, init
methods several objs share, trait Shape { fn area(): float }, obj Circle: Shape, if s is Circle, match on obj types, code in a trait fn greet(): str => …
programs of several files, import "path", pub