Generics
noun
say it: “juh-NAIR-iks” /dʒəˈnɛrɪks/
Writing a class or method once with a placeholder type that is filled in when it is used.
What are generics?
Generics let you write a class or method once, with a placeholder type (usually T), and fill the type in when it's used: one Shelf<T> serves as a shelf of snacks or a shelf of numbers. Read the angle brackets as "of": List<Snack> is "a list of snacks". C#, Java and TypeScript check the type; Python and JavaScript don't need the label.
In a sentence
- “With generics, one shelf class holds snacks in one place and prices in another.”
Level: Journeyman · More Software Development terms at this level
Updated