Created
August 7, 2018 19:21
-
-
Save qwertie/97a3689d95231d773ee61780e024dc1c to your computer and use it in GitHub Desktop.
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
class PrivateBox { | |
constructor(private width: number, private height: number) {} | |
area() { return this.width * this.height; } | |
} | |
let x = new PrivateBox(4, 5); | |
console.log(x.area()); // OK | |
console.log(x.width); // ERROR: 'width' is private and only | |
// accessible within class 'PrivateBox'. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment