53 lines
761 B
Plaintext
53 lines
761 B
Plaintext
// struct name
|
|
// {
|
|
// first: cstring
|
|
// last: cstring
|
|
// }
|
|
|
|
// struct human
|
|
// {
|
|
// name: name
|
|
// age: i64
|
|
// }
|
|
|
|
// trait printable
|
|
// {
|
|
// func print()
|
|
// }
|
|
|
|
// impl printable for human
|
|
// {
|
|
// func print() {
|
|
// c::puts(this.name.first)
|
|
// }
|
|
// }
|
|
|
|
func main(args: []cstring): i64
|
|
{
|
|
// let human = alloc human
|
|
// {
|
|
// name = alloc name {
|
|
// first = "john"
|
|
// last = "doe"
|
|
// }
|
|
// age = 23
|
|
// }
|
|
|
|
// human.print()
|
|
let x = 23
|
|
|
|
print_result(12, func(num) { return num == x })
|
|
|
|
return 0
|
|
}
|
|
|
|
func print_result(num: u64, delegate: func(u64): bool) {
|
|
if (delegate(num))
|
|
{
|
|
c::puts("true")
|
|
}
|
|
else
|
|
{
|
|
c::puts("false")
|
|
}
|
|
} |