4 ms·
The irony is that Go actually does have sum types, but only for generics! type A interface { Foo | Bar | Baz } Can't use this anywhere but in generic type s
by valzam 3y ago
The irony is that Go actually does have sum types, but only for generics!
type A interface {
Foo | Bar | Baz
}
Can't use this anywhere but in generic type signatures though :(
- bheadmaster 3y agoThere's a proposal [0] by Ian Lance Taylor that proposes extending the type parameter constrains union of types to non-generic interfaces too. Indeed, there are some issues with the implementation details, but I'm hoping they get ironed out. [0] https://github.com/golang/go/issues/57644 https://github.com/golang/go/issues/57644