Skip to content

Instantly share code, notes, and snippets.

@mizchi
Created August 8, 2012 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mizchi/3296219 to your computer and use it in GitHub Desktop.
Save mizchi/3296219 to your computer and use it in GitHub Desktop.
class _Main {
static function main(args : string[]) :void {
log "Hello, world!";
var p1:Point = new Point(10,20);
var p2:Point = new Point(30,10);
log p1.distance(p2);
}
}
class Point {
var x: int;
var y: int;
function constructor(x:int, y:int) {
this.x = x;
this.y = y;
}
function distance(other:Point):number {
var square: (int) -> int = (x:int) -> Math.pow(x,2);
var n:int = square(this.x - other.x) + square(this.y - other.y);
return Math.sqrt(n);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment