On Fri, Aug 9, 2024 at 9:03 PM 'Brian Candler' via golang-nuts
<golang-nuts@googlegroups.com> wrote:
>
> I would agree, except there is no == operator defined on slices, and I'm not 
> really sure why that is. The semantics I would expect are straightforward: 
> i.e. length is the same, and the first 'len' slice elements compare as equal, 
> recursively if necessary. (*)

There is no == operator on slice types because there are two possible meanings:
1) Two slices are equal if they have the same length and refer to the
same underlying array.
2) Two slices are equal if they have the same length and each
individual element is itself equal.

Because it's not clear which definition of equality people might mean,
the language doesn't define ==, and forces people to choose which
definition they want in any given situation.

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/CAOyqgcXcg1Azd1-ggZyrnk6hu5WDQCHQOhO0xkR%2BQoPt7faO%2Bw%40mail.gmail.com.

Reply via email to