How can I correctly compare two arrays in Go?
For instance, how can I compare two dimensional arrays with int entries, or any other types?
How deep is that comparison?
How can I correctly compare two arrays in Go?
For instance, how can I compare two dimensional arrays with int entries, or any other types?
How deep is that comparison?
To compare two arrays use the comparison operators ==
or !=
. Quoting from the link:
Array values are comparable if values of the array element type are comparable. Two array values are equal if their corresponding elements are equal.
As a 2D (or ND) array fits the above requirement, you can compare it in the same way.
The question "How deep is that comparison?" doesn't make sense for arrays.