What are generics?
Let’s start by discussing what generics are. As the name suggests, something that is generic implies that we will have “something” that is defined in a general way, and we can use it depending on certain situations or characteristics.
The idea of defining something as generic has the advantage of making it more flexible and reusable. The principle behind this is straightforward: when we design our code to handle only specific types, we limit its applicability. However, by allowing more general type parameters, we expand the range of possibilities and make our code adaptable to different types and scenarios.
At first glance, we could say that generics is a concept that we normally find in programming when playing with the parameterization of types. But let’s apply a more technical definition to understand the concept better – generics is a feature that can be applied to programming languages, in general, to define and use...