Last active
January 21, 2019 13:43
-
-
Save jkasun/d72bb3d459d62a5e208defe6364cda78 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Person { | |
private _age: number; | |
public set age(age) { | |
if (age < 0 || age > 200) { | |
throw new Error('Invalid arguement age'); | |
} | |
this._age = age; | |
} | |
public get age() { | |
return this._age; | |
} | |
} | |
const person: Person = new Person(); | |
// You dont have to use the method here, just assign the value | |
person.age = -10; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment