Skip to content

Instantly share code, notes, and snippets.

@shmup
Created June 28, 2017 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shmup/f2fd90559545b1fdceb4dffc34fed33f to your computer and use it in GitHub Desktop.
Save shmup/f2fd90559545b1fdceb4dffc34fed33f to your computer and use it in GitHub Desktop.
type
Vector = object
x, y: int
proc add(a, b: var Vector): var Vector =
result.x = a.x + b.x
result.y = a.y + b.y
var v1 = Vector(x: -1, y: 4)
var v2 = Vector(x: 5, y: -2)
var v3 = v1.add(v2)
echo v1
echo v2
# echo v3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment