On Mon, May 2, 2022 at 7:44 PM will....@gmail.com <will.fau...@gmail.com> wrote:
> ``` > type Slice1000[T any] struct { > xs *[1000]T > len, cap int > } > > func (s Slice1000[T]) Get(i int) T { > // ... > return s.xs[i] > } > > func (s Slice1000[T]) Set(i int, x T) { > // ... > s.xs[i] = x > } > > var xs1, xs2 [1000]int > > var a = Slice1000[int]{&xs1, 1000, 1000} > var b = Slice1000[int]{&xs2, 1000, 1000} > var c = a == b > ``` > > Do you expect `c` to be true? If not (it's false, by the way), then why > would you expect `make([]int, 2) == make([]int, 2)` to be true? > No. Did you actually try your hypothetical `make([]int, 2) == make([]int, 2)`? When I do so using the source below this reply the Go compiler emits the error "slice can only be compared to nil". Which is what I expect given the specification for the Go language. This seems like an example of the XY Problem <https://xyproblem.info/>. What caused you to open this thread? package main import ( "fmt" ) func main() { fmt.Printf("%v\n", make([]int, 2) == make([]int, 2)) } -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank -- 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/CABx2%3DD8HHjc3cYL_KL%3Dzga2V02Fpvz3EoXW0PSkhCx9p-B2w5g%40mail.gmail.com.