Skip to content

Instantly share code, notes, and snippets.

@jkasun
Last active January 21, 2019 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkasun/d72bb3d459d62a5e208defe6364cda78 to your computer and use it in GitHub Desktop.
Save jkasun/d72bb3d459d62a5e208defe6364cda78 to your computer and use it in GitHub Desktop.
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