Do not modify the given slice

This commit is contained in:
Anant Prakash 2018-07-26 20:01:37 +05:30
parent 2ac7a6c667
commit b19bcd93e5
No known key found for this signature in database
GPG key ID: C5D399F626523045

View file

@ -15,11 +15,13 @@ package test
import "sort"
// StringSliceEqual returns true if the slices have same length & elements.
func StringSliceEqual(a []string, b []string) bool {
if len(a) != len(b) {
// Does not modify the given slice.
func StringSliceEqual(first, second []string) bool {
if len(first) != len(second) {
return false
}
a, b := first[:], second[:]
sort.Strings(a)
sort.Strings(b)
for i := range a {