Skip to content

Commit b699652

Browse files
authored
Merge pull request #54 from alranel/array-contains
Support Contains() for arrays too
2 parents 4a778ad + 525830b commit b699652

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

presence.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func Contains(in interface{}, elem interface{}) bool {
146146
return true
147147
}
148148
}
149-
case reflect.Slice:
149+
case reflect.Slice, reflect.Array:
150150
for i := 0; i < inValue.Len(); i++ {
151151
if equal(inValue.Index(i).Interface(), elem) {
152152
return true

presence_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func TestContains(t *testing.T) {
3535
is := assert.New(t)
3636

3737
is.True(Contains([]string{"foo", "bar"}, "bar"))
38+
is.True(Contains([...]string{"foo", "bar"}, "bar"))
3839

3940
is.True(Contains(results, f))
4041
is.False(Contains(results, nil))

0 commit comments

Comments
 (0)