Type inference
The Go compiler infers the types we want to use from the function arguments. This is called type inference. The compiler will deduce type arguments from type parameter constraints.
Type inference either succeeds or fails. The compiler will complain, and we are provided the type arguments that need correcting upon finding an issue. Using generics is meant to be easy; however, the underlying details of type inference are highly complicated. It is also something the authors are iterating on to improve.
At this point, when it comes to calling generic functions, we’ve covered how you can specify type arguments in square brackets as type names. This allows the compiler to know to replace the type parameters within the function you’re invoking. However, you can omit the type arguments, as most of the time Go can infer them. However, it is not always possible to simplify your code by dropping type arguments. As the compiler runs your code, it replaces each...