I'd really love to be able to do:

type allowedTypes{
  int64|float64|string
}

func Foo[T allowedTypes](arg T) {
    switch t := arg {
       case int64:
           // something
       case string:
          // something completely different
   }
}

As a way of having the type checker disallow other types from being passed 
so I don't have to return an error for incorrect types.  I guess this would 
be the same as asking for typesets to be allowed in normal interfaces like:

func Foo(arg allowedTypes) {...}

Is there another way to achieve this? Is there a reason it is not possible?
Thanks!
Matt



-- 
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/870bc9bd-2fcf-4598-9287-2da7adbc524an%40googlegroups.com.

Reply via email to