On Thu, Oct 22, 2020 at 9:35 AM haibin wei <whaibi...@gmail.com> wrote:
>
> this is only an idea, hope it's useful.
>
> no `T`, only `type` as `types`.
>
> ```go
> type Inter int8,int16,int32,int64
>
> func Less(a,b Inter)bool{
>   return a<b
> }
>
> // and
> type UInter uint8,uint16,uint32,uint64
> type Float float32,float64
> type Number Inter,Uinter,Float
>
> func Less(a,b Number)bool{
>   return a<b
> }
> func Abs(n Number)Number{
>   if n<0{return -n}
>   return n
> }
> func Map(s []Number, f func(Number)Number)[]Number{
>   r := make([]Number, len(s))
>     for i, v := range s {
>         r[i] = f(v)
>     }
>     return r
> }
>
> // sorter
> type Sorter Number,string
> func Sort(list []Sorter){
>   // ...
> }
>
> // even with interface
> type Some interface{String()},string
> ```


Have you seen 
https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md
?

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/CAOyqgcVThRNJZ6WRThh7%3DJfm%3DHWQ%3DPrMNBTwHMkcRxohHAz%2BHg%40mail.gmail.com.

Reply via email to