Re: [go-nuts] How do you write "member" with the proposed generics draft?

2020-08-04 Thread Juliusz Chroboczek
Axel Wagner writes: > I feel like https://go2goplay.golang.org/p/RLn9BXjU1OR is a better > compromise than having two functions. > Prolly. Except OP specifically asked about "not that" :) Agreed on both counts. -- You received this message because you are subscribed to the Google Group

Re: [go-nuts] How do you write "member" with the proposed generics draft?

2020-08-04 Thread 'Axel Wagner' via golang-nuts
Prolly. Except OP specifically asked about "not that" :) On Tue, Aug 4, 2020 at 5:30 PM Andrei Tudor Călin wrote: > I feel like https://go2goplay.golang.org/p/RLn9BXjU1OR is a better > compromise than having two functions. > > On Tue, Aug 4, 2020 at 5:50 PM 'Axel Wagner' via golang-nuts < > gola

Re: [go-nuts] How do you write "member" with the proposed generics draft?

2020-08-04 Thread Andrei Tudor Călin
I feel like https://go2goplay.golang.org/p/RLn9BXjU1OR is a better compromise than having two functions. On Tue, Aug 4, 2020 at 5:50 PM 'Axel Wagner' via golang-nuts < golang-nuts@googlegroups.com> wrote: > No, that's not possible. A generic function can only work with *either* > built in operato

Re: [go-nuts] How do you write "member" with the proposed generics draft?

2020-08-04 Thread 'Axel Wagner' via golang-nuts
No, that's not possible. A generic function can only work with *either* built in operators *or* methods. So, you always need to have two functions: https://go2goplay.golang.org/p/YuzSzDAOEo2 On Tue, Aug 4, 2020 at 4:32 PM Juliusz Chroboczek wrote: > I'd be grateful if people could give me an ex

[go-nuts] How do you write "member" with the proposed generics draft?

2020-08-04 Thread Juliusz Chroboczek
I'd be grateful if people could give me an example to help me understand the generics draft. Suppose I've got these two functions: func MemberInt(x int, a []int) bool { for _, v := range a { if v == x { return true } }