Skip to content

Commit

Permalink
Update arrays-and-slices.md - added slices package tip (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
swamisriman authored Dec 18, 2023
1 parent 03964b2 commit 722ec79
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arrays-and-slices.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ func TestSumAll(t *testing.T) {
What we have done here is try to compare a `slice` with a `string`. This makes
no sense, but the test compiles! So while using `reflect.DeepEqual` is
a convenient way of comparing slices \(and other things\) you must be careful
when using it.
when using it.
(From Go 1.21, [slices](https://pkg.go.dev/slices#pkg-overview) standard package is available, which has [slices.Equal](https://pkg.go.dev/slices#Equal) function to do a simple shallow compare on slices, where you don't need to worry about the types like the above case.)

Change the test back again and run it. You should have test output like the following

Expand Down

0 comments on commit 722ec79

Please sign in to comment.