On Thu, Aug 20, 2020 at 8:28 PM jimmy frasche <soapboxcic...@gmail.com> wrote: > > To clarify on the type switches, would it have to be used like this: > > type C interface { > type X, Y > } > > func f(x X) X { > return x > } > > func g[T C](v T) T { > switch v { > case X: > // to use v as an X > // we must convert > x0 := X(v) > x1 := f(x0) > // to use x1 as a T > // we must convert back > t := T(x1) > return t > case Y: > return v > } > } > > And that the lack of a dedicated syntax to distinguish the case like > .[type] also means that you could no longer write > > func h[T comparable](x, a, b T) { > switch x { > case a: > case b: > } > } > > Regardless, all of these changes are fantastic!
No, the intent is that you would switch on the type parameter itself, not a value. func g[T C](v T) T { switch T { // the rest is the same } } Thanks for asking. Ian -- 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 golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcVd%3DaSttfOBgriPPkPMAhymdGw-v2RSb3OXM1zomuv7yA%40mail.gmail.com.