[email protected] schrieb am Montag, 17. August 2020 um 19:13:45 UTC+2:
>
> - No support covariance or contravariance. Maybe I am on shaky ground
> in terms of my understanding but doesn't this mean, for instance, that if
> I
> have two interfaces, Foo and Bar, and a third composite interface, FooBar,
> which consists of Foo and Bar, that a function with a generic parameter T
> constrained by Foo would not accept a type that implements FooBar? If i am
> incorrect, where does this come into play?
>
> What you describe does work: https://go2goplay.golang.org/p/5bLN7fDMVGN
2) I don't see syntax for directly applying multiple constraints to a
> generic type. Is this achievable only via interface composition?
>
Yes, and it can be inlined as usual:
func Example[T interface{Foo; Bar}](s []T) {
}
Although naming complex types is a good idea.
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/d4cce9ed-f84c-415c-946d-73c9a63eebfen%40googlegroups.com.