4 ms·
> Another HN commenter on this post mentioned IEnumerable<T>, which is very similar: you know nothing about T, but you need to call it _something_, and there's
by Sebb767 2y ago
> Another HN commenter on this post mentioned IEnumerable<T>, which is very similar: you know nothing about T, but you need to call it _something_, and there's a common understanding in the community that you call such type variables <T>.
You know that it's the type you enumerate over. I'd agree that in this case, <T> is sufficiently common language that people understand the reference (similar to how i is understood to be the index counter in a for loop), but you could definitely use a more expressive type name [1]. This becomes important if your type has two or three generic parameters.
[1] You might argue that this is more typing overhead, but your tooling will easily auto-complete it for you or refactor it after you've written the code, but before committing it. And if you don't have that type of tooling, you're in need of expressive variable names.