Skip to content

Instantly share code, notes, and snippets.

@gfx
Forked from mizchi/hoge.jsx
Created August 9, 2012 04:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfx/3300950 to your computer and use it in GitHub Desktop.
Save gfx/3300950 to your computer and use it in GitHub Desktop.
class _Main {
static function main(args : string[]) :void {
log "Hello, world!";
var p1 = new Point(10,20);
var p2 = 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 = (x:int) -> Math.pow(x,2);
var n = 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