From 41e1e812f2dee9d9278af05d61c24cd132299d79 Mon Sep 17 00:00:00 2001 From: Christophe Tes Date: Tue, 26 Jul 2022 11:02:49 +0200 Subject: [PATCH] Added Wonkey samples --- samples/Monkey/vec2.wx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 samples/Monkey/vec2.wx diff --git a/samples/Monkey/vec2.wx b/samples/Monkey/vec2.wx new file mode 100644 index 0000000000..915fa846e9 --- /dev/null +++ b/samples/Monkey/vec2.wx @@ -0,0 +1,26 @@ +struct Vec2 + field x:T + field y:T + + method new( x:T, y:T ) + self.x = x + self.y = y + end + + operator+:Vec2( v:Vec2 ) + return new Vec2( x + v.x, y + v.y ) + end + + operator to:string() + return "Vec2(" + x + ", " + y + ")" + end +end + +alias Vec2 Vec2f + +'main entry +function main() + local v0:= new Vec2f( 10,20 ) + local v1:= new Vec2f( 30,40 ) + print v0 + v1 +end