summaryrefslogtreecommitdiffhomepage
path: root/typescript.html.markdown
diff options
context:
space:
mode:
authorRett Berg <rett@google.com>2020-03-21 11:20:23 -0600
committerRett Berg <rett@google.com>2020-03-21 11:20:23 -0600
commitd0e82c10cd98e82100f3efac298d24d4d58ded9e (patch)
tree73b44bd5ce4ad7b242c5d638eebeab32446c9e9d /typescript.html.markdown
parent1599a765c5dc85184fad683df7baa5ccfe47aafa (diff)
add type to Point.dist and fix error
Diffstat (limited to 'typescript.html.markdown')
-rw-r--r--typescript.html.markdown6
1 files changed, 3 insertions, 3 deletions
diff --git a/typescript.html.markdown b/typescript.html.markdown
index 640be0cd..f7a41ce1 100644
--- a/typescript.html.markdown
+++ b/typescript.html.markdown
@@ -114,7 +114,7 @@ class Point {
}
// Functions
- dist() { return Math.sqrt(this.x * this.x + this.y * this.y); }
+ dist(): number { return Math.sqrt(this.x * this.x + this.y * this.y); }
// Static members
static origin = new Point(0, 0);
@@ -137,9 +137,9 @@ class Point3D extends Point {
}
// Overwrite
- dist() {
+ dist(): number {
let d = super.dist();
- return Math.sqrt(d() * d() + this.z * this.z);
+ return Math.sqrt(d * d + this.z * this.z);
}
}