Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Point[T]{
- var x y: T;
- }
- implementation Point{
- function Origin(): Point[T]
- where 0 :> T
- {
- return Self{x: 0, y: 0};
- }
- instance Add[Self, Self, Self]
- where valueof(T) + valueof(T) : T
- {
- function add(a b: Self){
- return Self{
- x: a.x + b.x,
- y: a.y + b.y
- };
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement