Created
March 26, 2020 00:26
-
-
Save gmotzespina/a26934df1a2360c432acad813569d102 to your computer and use it in GitHub Desktop.
Generics introduction: Student class
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
| interface StudentProps { | |
| id: number; | |
| name: string; | |
| } | |
| export class Student { | |
| constructor(private data: StudentProps) {} | |
| get(propName: string): number | string { | |
| return this.data[propName]; | |
| } | |
| set(update: StudentProps): void { | |
| this.data = {...this.data, update} | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment