- Learning Functional Programming in Go
- Lex Sheehan
- 61字
- 2021-07-02 23:13:35
If Go had generics
If Go had generics, we could have written a function signature like the following to replace strings with runes, and we would not have to rewrite the inner logic:
func Map(f func(v <string>) <bool>, vs [] <string>) []<bool>
However, Go does not have generics, so we can use empty interfaces and reflection to achieve the same result.