You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
String operations: replace, split, join, trim, contains, index_of, case conversion
Quick taste
Tin compiles to native code via LLVM. Run a file with tin run file.tin,
build a binary with tin build file.tin, and run tests with tin test file.tin
(or tin test dir/ for one directory, tin test dir/... to recurse).
// Hello world
echo "Hello, world!"// Fibonacci with pattern matchingfnfib(n u32) u32 =
where n <= 1: n
where _:fib(n - 1) + fib(n - 2)
echo fib(10)// Structs with methods
struct person =
name string
age u8
fninit(this person) =
echo "new person: {this.name}"
fn show(this person) string =
return"{this.name} is {this.age} years old"
let pete = person{name:"Pete",age:20}
echo pete.show()// Traits
trait named =
label string forward
fn name(this named) string = return this.label
struct cat(named) =
breed string
let c = cat{label:"Whiskers",breed:"tabby"}
echo c.name()// Fibers and channels
use sync
fn{#async} worker(id i64, ch sync::Channel[string]) =
ch.send("result from fiber {id}")
fn main() =
let ch = sync::Channel[string].make(4)
spawn worker(1, ch)
spawn worker(2, ch)
echo await ch.recv()// "result from fiber 1" or "2", whichever finishes first
echo await ch.recv()