4 ms·
This might be nice to use in the specific case. However, its important to note that in the general case, you need a type variable because it is used in multiple
by gregwebs 8y ago
This might be nice to use in the specific case. However, its important to note that in the general case, you need a type variable because it is used in multiple positions. In the function below (taken from the proposal), one is stating that T is the same type in all usages.
func Join(type T strseq)(a []T, sep T) (ret T)
This below version is different, each variable could be a different type (that satisfies strseq).
func Join(a []strseq, sep strseq) (ret strseq)
- mopsy 8y agoAs I understand, the type would be implicitly applied to every func/struc in scope (which I assume would be the package) It work quite well for package like a Map so any data structure/algorithm. I suspect it would be less ideal for filter/map/reduce.