xgoprev/tests/dogs.xgo

23 lines
283 B
Text
Raw Normal View History

2024-06-14 23:00:26 +03:00
objects := import("objects")
fmt := import("fmt")
2024-06-07 11:29:46 +03:00
2024-06-14 23:00:26 +03:00
new := func(name) {
ret := objects.new()
ret.name = name
ret.def("bark", func(self, n){
fmt.print(self.name, ": ")
for i:=0 ; i<n ; i++ {
fmt.print("BARK!")
2024-06-07 11:29:46 +03:00
}
2024-06-14 23:00:26 +03:00
fmt.println()
})
return ret
}
export {
"new": new
2024-06-07 11:29:46 +03:00
}