...
This commit is contained in:
@@ -1,57 +1,16 @@
|
||||
struct Name
|
||||
template<T> struct Box
|
||||
{
|
||||
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)
|
||||
}
|
||||
value: T
|
||||
}
|
||||
|
||||
func main(args: []cstring): i64
|
||||
{
|
||||
let human = alloc Human
|
||||
let box = alloc Box<cstring>
|
||||
{
|
||||
name = alloc Name {
|
||||
first = "john"
|
||||
last = "doe"
|
||||
}
|
||||
age = 23
|
||||
value = "bob"
|
||||
}
|
||||
|
||||
human.print()
|
||||
print_result(12, func (num) => num == 12)
|
||||
|
||||
let x: cstring = "test"
|
||||
|
||||
let addr = x&
|
||||
|
||||
c::puts(addr^)
|
||||
c::puts(box.value)
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
func print_result(num: u64, delegate: func(u64): bool) {
|
||||
if (delegate(num))
|
||||
{
|
||||
c::puts("true")
|
||||
}
|
||||
else
|
||||
{
|
||||
c::puts("false")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user