-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
struct Vec2<T> | ||
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<float> Vec2f | ||
|
||
'main entry | ||
function main() | ||
local v0:= new Vec2f( 10,20 ) | ||
local v1:= new Vec2f( 30,40 ) | ||
print v0 + v1 | ||
end |