Skip to content

Instantly share code, notes, and snippets.

@softwarebygabe
Created June 22, 2020 18:02
Show Gist options
  • Save softwarebygabe/768c1b94461b6b449d2098c099b44f0f to your computer and use it in GitHub Desktop.
Save softwarebygabe/768c1b94461b6b449d2098c099b44f0f to your computer and use it in GitHub Desktop.
This would be a typical way to construct an object
type Material = 'wood' | 'brick' | 'steel'
class House {
private rooms: number
private floors: number
private material: Material
constructor(rooms: number, floors: number, material: Material) {
this.rooms = rooms
this.floors = floors
this.material = material
}
}
@softwarebygabe
Copy link
Author

construction:

const myHouse = new House(5, 2, 'wood')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment