4 ms·
Well, you can :) https://play.golang.org/p/sum21uSy1Ae https://play.golang.org/p/sum21uSy1Ae
by vlads_ 6y ago
Well, you can :) https://play.golang.org/p/sum21uSy1Ae https://play.golang.org/p/sum21uSy1Ae
- srathi 6y agoThis is an awesome use of the reflect package!
- grey-area 6y agoFor certain values of can.
- vlads_ 6y agoNever said it was a good idea. It's inefficient, unsafe and hard to read but, as far as I can tell any generic function with concrete return types can be written using reflect (and any generic function with generic return types can be written also, it just requires the caller to manually cast from an interface{} to the correct type). So, that's an interesting thing.