3 ms·
> that doesn't work in many languages, it does when the language has generics. You in fact wouldn't need 2 types []fooint and []Fooer but a single List<T Fooer
by camus2 10y ago
> that doesn't work in many languages,
it does when the language has generics. You in fact wouldn't need 2 types []fooint and []Fooer but a single List<T Fooer> , as long as fooint implements Fooer.
So with Go you end up writing functions that convert types manually. The 1000's time you do this, it starts getting a bit tiresome.
- zellyn 10y agoWell, Java has generics, but you still can't do this same thing: http://stackoverflow.com/questions/1115230/casting-object-array-to-integer-array-error http://stackoverflow.com/questions/1115230/casting-object-ar... I agree that having generics in Go would be fantastic, and I'm excited at rsc's articulation of why. But they don't completely solve this problem.
- camus2 10y agoBut with Java the point is that you'd approach the issue differently without being overly verbose just like Go. I mean my example is clear. You wouldn't have to cast anything provided you use generics at first place.