Created
February 15, 2013 01:30
-
-
Save pparadis/4957959 to your computer and use it in GitHub Desktop.
Exemple par défaut pour TypeScript
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
// Interface | |
interface IPoint { | |
getDist(): number; | |
} | |
// Module | |
module Shapes { | |
// Class | |
export class Point implements IPoint { | |
// Constructor | |
constructor (public x: number, public y: number) { } | |
// Instance member | |
getDist() { return Math.sqrt(this.x * this.x + this.y * this.y); } | |
// Static member | |
static origin = new Point(0, 0); | |
} | |
} | |
// Local variables | |
var p: IPoint = new Shapes.Point(3, 4); | |
var dist = p.getDist(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment