Skip to content

Instantly share code, notes, and snippets.

@gmotzespina
Created March 26, 2020 00:26
Show Gist options
  • Select an option

  • Save gmotzespina/a26934df1a2360c432acad813569d102 to your computer and use it in GitHub Desktop.

Select an option

Save gmotzespina/a26934df1a2360c432acad813569d102 to your computer and use it in GitHub Desktop.
Generics introduction: Student class
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