Skip to content

Instantly share code, notes, and snippets.

@jasonbyrne
Created April 14, 2022 04:10
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 jasonbyrne/0a24a5bc1d4f85c2f0420c59af99bb6a to your computer and use it in GitHub Desktop.
Save jasonbyrne/0a24a5bc1d4f85c2f0420c59af99bb6a to your computer and use it in GitHub Desktop.
Menu with Generic Constraint
class Menu<T extends Food | Drink> {
private items: T[] = [];
public addItem(item: T) {
this.items.push(item);
}
public getItems(): T[] {
return this.items;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment